SleepingOwl Admin model configurations must be stored within bootstrapDirectory (default: app/admin).

You can store all your model configurations in one file or split it as you want.

Here is example how your model configuration might look like:

Admin::model('App\Contact2')->title('Contact')->alias('contacts2')->display(function ()
{
    $display = AdminDisplay::table();
    $display->with('country', 'companies');
    $display->filters([
        Filter::related('country_id')->model('App\Country'),
    ]);
    $display->columns([
        Column::image('photo')->label('Photo'),
        Column::string('fullName')->label('Name'),
        Column::datetime('birthday')->label('Birthday')->format('d.m.Y'),
        Column::string('country.title')->label('Country')->append(Column::filter('country_id')),
        Column::lists('companies.title')->label('Companies'),
    ]);
    return $display;
})->createAndEdit(function ()
{
    $form = AdminForm::form();
    $form->items([
        FormItem::columns()->columns([
            [
                FormItem::text('firstName', 'First Name')->required(),
                FormItem::text('lastName', 'Last Name')->required(),
                FormItem::text('phone', 'Phone'),
                FormItem::text('address', 'Address'),
            ],
            [
                FormItem::image('photo', 'Photo'),
                FormItem::date('birthday', 'Birthday')->format('d.m.Y'),
            ],
            [
                FormItem::select('country_id', 'Country')->model('App\Country')->display('title'),
                FormItem::textarea('comment', 'Comment'),
            ],
        ]),
    ]);
    return $form;
})->delete(null);

Provide Model

Admin::model(\App\MyModel::class)

Or if you are running PHP under 5.5 you can use strings:

Admin::model('App\MyModel')

Set Title

->title('My Model Title')

Title will be displayed in headers and menu label.

Set Alias

->alias('districts')

Alias will be used in urls. Default alias is lowercase plural form of model class.

Set Display

->display(function ()
{
    // specify model display here
})

For details see displays.

Set Create and Edit Forms

You can provide one form for creation and edition:

->createAndEdit(function ()
{
    // specify model create or edit form here
})

Or separate forms:

->create(function ()
{
    // create form
})
->edit(function ()
{
    // edit form
})

For details see form configuration.

Disable Creation

->createAndEdit(function ($id)
{
    if (is_null($id))
    {
        return null;
    }
    ...
})

Disable Edition

->createAndEdit(function ($id)
{
    if ( ! is_null($id))
    {
        return null;
    }
    ...
})

Disable Delete

You can disable delete function:

->delete(null)

Disable Restore

You can disable restore function (in models with soft deletes):

->restore(null)