CRUD Types
The sections you see in the back end are just a combination of the following:
- An Crud Config (
Yadda\Enso\Crud\Config) - A Model (
Illuminate\Database\Eloquent\Model) (and related database table(s)) - A Resource Controller (
Yadda\Enso\Crud\Controller) - An item in the Enso admin menu
What to do
- Create a model for your type
php artisan make:model Thing
Make a migration for the model
- run
php artisan make:migration adds_things_table --create=things. - edit the new migration to add fields to it. See Laravel Schema for column types.
- run the migration (must be done in VM if running in one) with
php artisan migrate.
NOTE: Don't forget to make all the correct columns fillable within the model, and set up relationships as you want them
- run
Make a CRUD configuration for your thing
- php artisan enso:make:crud Thing
- TEMP: Remove HasMetaTab references (until command is remade to exclude them)
NOTE: The name you pass this should be singular! ALSO NOTE: You will need to remove HasMetaTab references until this command is remade to exclude them
Make a Crud controller
php artisan make:controller Admin/ThingController- Change base class to
Yadda\Enso\Crud\Controller - Add
protected $crud_name = "thing"
Fill in file
config/enso/crud.phpfor the new datatype.Add a route to this controller in
routes/web.php. You should use theensomiddleware to prevent unauthorised access.Route::group(['middleware' => 'enso'], function () { EnsoCrud::routes('admin/things', 'ThingController', 'admin.things'); });Register a menu item for the admin area in
app/Providers/EnsoServiceProvider.phpSee Admin Menu for more details.
Gotchas
If the order column is not being populated, you probably want to add order to the fillable array on your model.