-
-
Notifications
You must be signed in to change notification settings - Fork 2
Crud Views
to provide as much flexibility as possible, edit
views/vendor/SimpleMenu/admin/shared
and combine/merge it with your main layout view.for
users/roles/permissions
the delete button is "disabled" because removing any will lock the current user out, however you can change that easily under the index view of each one.all the pages will be available in both (Page & Menu) views, switching the locales will update the pages title if found or will fallback to whatever available.
pages now have soft delete support which will work as expected with menus, except for nesting which will be reseted.
currently we list all the model data as they are "without any pagination" but as the data start to grow this wont be ideal, so to solve that we just need to change the index method of the controller
-
create new controller ex.
php artisan make:controller PagesController
-
go to
config/simpleMenu.php
and change the item controller to the newly created ex.'controllers'=> [ 'pages' => '\App\Http\Controllers\PagesController', ]
-
make
PagesController
extends the original & add a new methodindex()
with- not all the controllers
index()
are the same, so make sure to check the original first
use ctf0\SimpleMenu\Controllers\Admin\PagesController as SMPagesController; class PagesController extends SMRolesController { public function index() { $pages = $this->paginate($this->cache->tags('sm')->get('pages')); return view("{$this->adminPath}.pages.index", compact('pages')); } }
- not all the controllers
-
add to index view
{{ $pages->links('vendor.pagination.bulma') }}
atm we don't do any operations to the uploaded file & this is intentionally so you are free to decide how you want to save the image, so if you need to do any extra work on the input plz follow this points
- create new controller ex.
php artisan make:controller ExampleController
- go to
config/simpleMenu.php
and change the item controller to the newly created'controllers'=> [ 'pages' => '\App\Http\Controllers\ExampleController', ]
- make
ExampleController
extends the original & add a new methodgetImage()
with any logic you want to do on the image in here, ex.use ctf0\SimpleMenu\Controllers\Admin\PagesController; class ExampleController extends PagesController { protected function getImage($img) { // https://davidwalsh.name/data-uri-php $imageData = base64_encode(file_get_contents($img->getPath())); $src = 'data: ' . $img->getMimeType() . ';base64,' . $imageData; return $src; } }
Ofcourse you are free to code your app the way you want, but just in-case here is some guidance to make things easier to remember.
column name | format | output |
---|---|---|
title | title_case(some title) | Some Title |
route_name | str_slug(Some Title) | some-title |
action | SomeController@camelCase(Some Title) | someTitle |
- support soft-deleteing
- support editing page controller directly from view
- support adding icon
- support editing menu page directly