app/Http/Controllers/DishesController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Dish $dish)
    {
        request()->validate([
            'name' => 'required',
            'category' => 'required',
        ]);
        if ($request->dish_image) {
            $imageName = date('YmdHis') . "." . request()->dish_image->getClientOriginalExtension();
            request()->dish_image->move(public_path('images'), $imageName);
            $dish->image = $imageName;
        }
        $dish->save();
        return redirect('dish')->with('message', 'Dish Edited Successfully');
    }
public function update ( Request $ request , Dish $ dish ) { request ( ) -> validate ( [ 'name' => 'required' , 'category' => 'required' , ] ) ; if ( $ request -> dish_image ) { $ imageName = date ( 'YmdHis' ) . " . " . request ( ) -> dish_image -> getClientOriginalExtension ( ) ; request ( ) -> dish_image -> move ( public_path ( 'images' ) , $ imageName ) ; $ dish -> image = $ imageName ; } $ dish -> save ( ) ; return redirect ( 'dish' ) -> with ( 'message' , 'Dish Edited Successfully' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .