app/Http/Controllers/DishesController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(DishCreateRequest $request)
    {
        $dish = new Dish();
        $dish->name = $request->name;
        $dish->category_id = $request->category;
        $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 Created Successfully');
    }
public function store ( DishCreateRequest $ request ) { $ dish = new Dish ( ) ; $ dish -> name = $ request -> name ; $ dish -> category_id = $ request -> category ; $ 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 Created Successfully' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .