Download the PHP package bashirsh/laravel_easy_controller without Composer
On this page you can find all versions of the php package bashirsh/laravel_easy_controller. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bashirsh/laravel_easy_controller
More information about bashirsh/laravel_easy_controller
Files in bashirsh/laravel_easy_controller
Package laravel_easy_controller
Short Description build api resources controllers in fast, easy and fully customizable way.
License MIT
Informations about the package laravel_easy_controller
Laravel Easy Controller 1.0.4
Build resources & api controllers in fast, easy and fully customizable way.
Contents
- Features
- Installation
- API Controller
- Multi Page Crud
- Hooks
Features
index features
- filter
- Query Hook
- pagination
- limit
- order & order by
- transform row
- export to excel (current page or all results).
forms features
- validation
- change the data before store
- redirect
- after save hooks
delete features
- redirect
- after save hooks
Installation
composer require bashirsh/laravel_easy_controller
Api Controller
to create new API Controller we need to extend the class ApiController
,
app/Http/Controllers/Api/UsersController.php
This class will create a full resource controller with the methods:
- index
- show
- store
- update
- delete
then we need to add the resource to the routes.
routes/api.php
CrudController
to create new controller we need to extend the class CrudController
Controller
app/Http/Controllers/UsersController.php
This class will create a full resource controller with the methods:
- index
- show
- add
- store
- edit
- update
- delete
- export to excel
then we need to add the resource to the routes, and create view files.
Route
routes/web.php
Views
create 4 files in views
resources/views/admin/users/index.blade.php
the controller will pass the variable $data
which contain the result of Model::paginate()
resources/views/admin/users/show.blade.php
the controller will pass the variable $item
, which contain the result of Model::find($id)
resources/views/admin/users/create.blade.php we can print validation errors
resources/views/admin/users/edit.blade.php
the controller will pass the variable $item
, which contain the result of Model::find($id)
Hooks
The package contain a lot of hooks which help you to customize any thing in the controllers, you can see them here: Hooks.
Index Hooks
Index Query Hook
The package will handle pagination limit and filter out of the box, and we can change the query ex: adding conditions or using eager load.
Define filters
we define our allowed filters by defining.
Transform Row
Forms Hooks
define validation rules
change the data before store
redirect
you can define redirect_url to redirect after save, update or delete
and you can customize using these methods
- add_redirect_url
- edit_redirect_url
- destroy_redirect_url