Download the PHP package bakle/crud-core without Composer
On this page you can find all versions of the php package bakle/crud-core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package crud-core
Laravel CRUD Core
This package contains base files that contains all boilerplate logic for creating a crud.
Installation
What's inside this package?
UrlPresenter
The url presenter encapsulate the routes that are generated in Route::resource('users, UserController::class)
For one model
For related models
Entities
An entity is an extra layer that wraps your model to add extra logic. The BaseEntity
only require a url()
method to be implemented
View Models
View models encapsulates all the logic and data that you need to send to your views.
IndexViewModel
This view model send to the view the following data:
- entities: A collection of the entities of the model defined in the
IndexViewModel
(i.e: UserEntity) -
pagination: Because now you receive a collection of entities and not models, this is the same as doing
$users->links
. now you can do: - title:: This is just the string you return in the
getTitle()
method. It's useful in your index to add it in your blade like this:
Example
ShowViewModel
This view model send to the view the following data:
- entity: A single entity of the model defined in the
ShowViewModel
(i.e: UserEntity)
Example
FormViewModel
This view model send to the view the following data:
- entity: A single entity of the model defined in the
ShowViewModel
(i.e: UserEntity) -
form: This contains the url for submitting the form, the method type (POST or PUT) and some other helper methods. It's useful to use it in your forms like this:
- title:: This will resolve automatically the title based on the method type. For example if you use
->setFormType(FormTypes::CREATE)
, the title will be Create user, if it's->setFormType(FormTypes::EDIT)
, the title will be Edit User. You can use it like this:
Example
All ViewModel
includes a method getExtraData()
where you can return an array of extra data you need to send to the view.