jeudi 27 février 2020

laravel not show new image after editing only if remove cache

When I modify the images, the editing process succeeds, but no changes are made to the pictures and the new image does not appear after the edit except when I delete the cache

 $brands = Brands::findOrfail($id);


    $image = $request->file('image');

    if ($image && $image->isValid()) {
        $path = $image->storeAs('brands', basename($brands->image),'public');
        $brands->image = $path;
    }


    $brands->name = $request->input('name');
    $brands->description =$description;

     if ($brands->save()) {
        return redirect(route('admin.brands'))->with([
            'message' => sprintf(' The Brand: "%s" edit success !', $brands->name),
            'alert-type' => 'success'
        ]);
    } else {
        return redirect()->back()->with([
            'message' => sprintf(' The Brand : "%s" can not edit success !', $brands->name),
            'alert-type' => 'error'
        ])->withInput();
    }


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire