sleeping-owl / admin

Administrative interface builder for Laravel
http://sleeping-owl.github.io/
MIT License
504 stars 258 forks source link

Finding examples #248

Open tiborsaas opened 9 years ago

tiborsaas commented 9 years ago

Hello,

I've just installed Sleeping Owl and after reading the docs, I'm still confused how to connect models to menu items. I assume if I create a model configuration like this

<?php

Admin::model(App\TestModel::class)->title('Test')->with()->filters(function ()
{

})->columns(function ()
{
    Column::string('username', 'Username');
    Column::string('email', 'Email');
})->form(function ()
{
    FormItem::text('username', 'Username');
    FormItem::text('email', 'Email');
});

Add this to menu.php

Admin::menu(\TestModel::class);

Then it would generate a list for me.

TestModel.php looks like this:

<?php

namespace App;

class TestModel extends \Eloquent {
    protected $table = 'users';
    protected $fillable = ['title', 'body'];
}

Also, where can I check out a working example?

BcTpe4HbIu commented 9 years ago

There is an example repo.

tiborsaas commented 9 years ago

Thanks. Do you have any idea what I'm not getting?

tiborsaas commented 9 years ago

@BcTpe4HbIu example repo doesn't work with the admin/pass provided.

BcTpe4HbIu commented 9 years ago

@sleeping-owl the only one who can help with this.

tiborsaas commented 9 years ago

@sleeping-owl can you please provide some info on my question?

mxshdev commented 9 years ago

Hi! You need to create a model in the folder App\Models. Then you need to create a model in the folder App\Admin\Models and past this code:

Admin::model(\App\Models\Faculty::class)->title('Факультеты')->display(function ()
{
    $display = AdminDisplay::datatables();
    $display->columns([
        Column::string('name')->label('Наименование'),
    ]);
    return $display;
})->createAndEdit(function ()
{
    $form = AdminForm::form();
    $form->items([
        FormItem::text('name', 'Наименование')->required(),
    ]);
    return $form;
});