Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
2.2 kB
2
Indexable
Never
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Food;
use App\Models\Reservation;
use Illuminate\Http\UploadedFile;

class AdminController extends Controller
{
    public function foodmenu(){
        $data = food::all();
        return view("admin.foodmenu", compact("data"));
    }

    public function upload(Request $request){
        $data = new food;

        $image = $request->image;

        $imagename=time().'.'.$image->getClientOriginalExtension();
        $request->image->move('foodimage',$imagename);

        $data->image=$imagename;

        $data->title=$request->title;
        $data->price=$request->price;
        $data->description=$request->description;

        $data->save();

        return redirect()->back();
    }

    public function deletemenu($id){
        $data=food::find($id);

        $data->delete();
        return redirect()->back();
    }

    public function updateview($id){
        $data=food::find($id);
        return view("admin.updateview", compact("data"));
    }

    public function update(Request $request, $id){
        $data=food::find($id);

        $image = $request->image;

        $imagename=time().'.'.$image->getClientOriginalExtension();
        $request->image->move('foodimage',$imagename);

        $data->image=$imagename;

        $data->title=$request->title;
        $data->price=$request->price;
        $data->description=$request->description;

        $data->save();

        return redirect()->back();

    }

    public function reservation(Request $request){
        $data = new reservation;

        $data->name=$request->name;
        $data->email=$request->email;
        $data->phone=$request->phone;
        $data->guest=$request->guest;
        $data->date=$request->date;
        $data->time=$request->time;
        $data->message=$request->message;

        $data->save();

        return redirect()->back();
    }

    public function viewreservation(){
        $data=reservation::all();

        return view("admin.adminreservation", compact("data"));
    }
}
Leave a Comment