4 months ago

How to update a product in laravel 5,8

Posted 4 months ago by irankhosravi

I have a product I want to edit a product

Look at my codes

public function update(ProductRequest $request)
    $product->user_id = auth()->user()->id;
    $product->title = $request->title;
    $product->body = $request->body;
    $product->price = $request->price;

    if($request->has('image')) {
        $image = $request->file('image');
        $filename = $image->getClientOriginalName();
        $image->move(public_path('images/products'), $filename);
        $product->image = $request->file('image')->getClientOriginalName();



    return redirect()->route('products.index');

Everything changes except image.

Please sign in or create an account to participate in this conversation.