2020-06-23 09:59:26 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2020-06-25 10:22:22 +00:00
|
|
|
use App\ExternalLink;
|
2020-06-25 08:34:10 +00:00
|
|
|
use App\MenuPlan;
|
2020-06-23 09:59:26 +00:00
|
|
|
use Illuminate\Http\Request;
|
2020-06-25 08:34:10 +00:00
|
|
|
use Illuminate\Http\Response;
|
|
|
|
|
2020-06-23 09:59:26 +00:00
|
|
|
|
|
|
|
class MenuPlanController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Display a listing of the resource.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
2020-06-25 08:34:10 +00:00
|
|
|
public function index(Request $request)
|
2020-06-23 09:59:26 +00:00
|
|
|
{
|
2020-06-25 08:34:10 +00:00
|
|
|
$menuPlans = MenuPlan::query()->paginate($request->input("limit", 20));
|
|
|
|
|
2020-06-25 10:37:17 +00:00
|
|
|
return Response::detect("menuplans.index", [ "menuPlans" => $menuPlans]);
|
2020-06-23 09:59:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for creating a new resource.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
2020-06-25 13:29:43 +00:00
|
|
|
public function create()
|
2020-06-23 09:59:26 +00:00
|
|
|
{
|
2020-06-25 10:37:17 +00:00
|
|
|
return Response::detect("menuplans.create");
|
2020-06-23 09:59:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store a newly created resource in storage.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function store(Request $request)
|
|
|
|
{
|
2020-06-25 10:22:22 +00:00
|
|
|
$requestMenuPlanCreate = $request->validate([
|
2020-06-26 11:11:24 +00:00
|
|
|
"monday" => "required|max:255",
|
|
|
|
"tuesday" => "required|max:255",
|
|
|
|
"wednesday" => "required|max:255",
|
|
|
|
"thursday" => "required|max:255",
|
|
|
|
"friday" => "required|max:255",
|
|
|
|
"saturday" => "required|max:255",
|
|
|
|
"sunday" => "required|max:255"
|
2020-06-25 10:22:22 +00:00
|
|
|
]);
|
|
|
|
|
2020-06-25 16:43:46 +00:00
|
|
|
$menuPlans = new MenuPlan($requestMenuPlanCreate);
|
2020-06-25 10:22:22 +00:00
|
|
|
$menuPlans->save();
|
|
|
|
|
2020-06-25 10:37:17 +00:00
|
|
|
return Response::detect("menuplans.store");
|
2020-06-23 09:59:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the specified resource.
|
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
2020-06-26 11:55:04 +00:00
|
|
|
public function show(MenuPlan $id)
|
2020-06-23 09:59:26 +00:00
|
|
|
{
|
2020-06-26 11:55:04 +00:00
|
|
|
return Response::detect("menuplans.show", [ "menuplan" => $id]);
|
2020-06-23 09:59:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for editing the specified resource.
|
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function edit($id)
|
|
|
|
{
|
2020-06-29 06:31:36 +00:00
|
|
|
$menuplan = MenuPlan::find($id);
|
|
|
|
return Response::detect("menuplans.edit", ["menuplan" => $menuplan]);
|
2020-06-23 09:59:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the specified resource in storage.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function update(Request $request, $id)
|
|
|
|
{
|
2020-06-29 06:31:36 +00:00
|
|
|
$data = $request->all();
|
2020-06-29 07:08:49 +00:00
|
|
|
//FORCED UPDATE
|
2020-06-25 10:44:06 +00:00
|
|
|
|
2020-06-29 06:31:36 +00:00
|
|
|
$menuplan = MenuPlan::find($id);
|
|
|
|
$menuplan->update($data);
|
|
|
|
$menuplan->save();
|
2020-06-25 10:44:06 +00:00
|
|
|
|
2020-06-29 06:31:36 +00:00
|
|
|
return Response::detect("menuplans.update", [ "menuplan" => $menuplan ]);
|
2020-06-23 09:59:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the specified resource from storage.
|
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function destroy($id)
|
|
|
|
{
|
2020-06-29 06:31:36 +00:00
|
|
|
$menuplan = MenuPlan::find($id);
|
|
|
|
$menuplan->delete();
|
|
|
|
return redirect()->route("menu-plans.index");
|
2020-06-23 09:59:26 +00:00
|
|
|
}
|
|
|
|
}
|