FleetCart/Modules/Menu/Http/Controllers/Admin/MenuController.php

76 lines
1.5 KiB
PHP
Raw Normal View History

2023-06-11 12:14:03 +00:00
<?php
namespace Modules\Menu\Http\Controllers\Admin;
2023-12-03 14:07:47 +00:00
use Illuminate\Http\Response;
2023-06-11 12:14:03 +00:00
use Modules\Menu\Entities\Menu;
use Modules\Admin\Traits\HasCrudActions;
use Modules\Menu\Http\Requests\SaveMenuRequest;
class MenuController
{
use HasCrudActions;
/**
* Model for the resource.
*
* @var string
*/
protected $model = Menu::class;
/**
* Label of the resource.
*
* @var string
*/
protected $label = 'menu::menus.menu';
/**
* View path of the resource.
*
* @var string
*/
protected $viewPath = 'menu::admin.menus';
/**
* Form requests for the resource.
*
* @var array|string
*/
protected $validation = SaveMenuRequest::class;
/**
* Show the form for editing the specified resource.
*
* @param int $id
2023-12-03 14:07:47 +00:00
*
* @return Response
2023-06-11 12:14:03 +00:00
*/
public function edit($id)
{
$menu = Menu::withoutGlobalScope('active')->findOrFail($id);
$menuItems = $menu->menuItems()
->withoutGlobalScope('active')
->withoutGlobalScope('not_root')
->get()
->nest();
return view('menu::admin.menus.edit', compact('menu', 'menuItems'));
}
2023-12-03 14:07:47 +00:00
/**
* Redirect to url after saving a resource.
*
* @param Menu $menu
*
* @return Response
*/
protected function redirectTo($menu)
{
return redirect()->route('admin.menus.edit', $menu);
}
2023-06-11 12:14:03 +00:00
}