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

  1. Create a model for your type
php artisan make:model Thing
  1. Make a migration for the model

    1. run php artisan make:migration adds_things_table --create=things.
    2. edit the new migration to add fields to it. See Laravel Schema for column types.
    3. 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

  2. Make a CRUD configuration for your thing

    1. php artisan enso:make:crud Thing
    2. 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

  3. Make a Crud controller

    1. php artisan make:controller Admin/ThingController
    2. Change base class to Yadda\Enso\Crud\Controller
    3. Add protected $crud_name = "thing"
  4. Fill in file config/enso/crud.php for the new datatype.

  5. Add a route to this controller in routes/web.php. You should use the enso middleware to prevent unauthorised access.

    Route::group(['middleware' => 'enso'], function () {
        EnsoCrud::routes('admin/things', 'ThingController', 'admin.things');
    });
    

    More about the middleware

  6. Register a menu item for the admin area in app/Providers/EnsoServiceProvider.php

    See 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.