app/Http/Controllers/MealController.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(Request $request)
    {
        $validated = $request->validate([
            'name' => 'required|max:100',
            'description' => 'required|max:255',
            'price' => 'required|numeric',
            'image' => 'required|mimes:jpg,png,jpeg',
        ]);
        $image = $request->file('image');
        $image->store('menu');
        Meal::create([
            "name" => $validated["name"],
            "description" => $validated["description"],
            "price" => $validated["price"],
            "imagePath" => "menu/".$image->getClientOriginalName()
        ]);
        return redirect(route("menu.index"));
    }
public function store ( Request $ request ) { $ validated = $ request -> validate ( [ 'name' => 'required|max:100' , 'description' => 'required|max:255' , 'price' => 'required|numeric' , 'image' => 'required|mimes:jpg,png,jpeg' , ] ) ; $ image = $ request -> file ( 'image' ) ; $ image -> store ( 'menu' ) ; Meal :: create ( [ " name " => $ validated [ " name " ] , " description " => $ validated [ " description " ] , " price " => $ validated [ " price " ] , " imagePath " => " menu/ " . $ image -> getClientOriginalName ( ) ] ) ; return redirect ( route ( " menu.index " ) ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .