<?php Admin::model(\Pages::class)->title('Страницы')->with()->filters(function () { })->columns(function () { Column::string('id', 'ID'); Column::string('menu_title', 'Заголовок меню'); Column::string('title', 'Заголовок'); Column::string('is_published', 'Статус публикации'); Column::date('created_at', 'Дата создания')->format('medium', 'short'); Column::date('updated_at', 'Дата обновления')->format('medium', 'short'); Column::date('published_at', 'Дата публикации')->format('medium', 'short'); })->form(function () { // FormItem::select('parent_id', 'Родитель')->enum(Pages::whereIsContainer(1)->lists('menu_title', 'id')); FormItem::text('parent_id', 'Родитель'); FormItem::checkbox('is_published', 'Опубликовано'); FormItem::checkbox('is_container', 'Может быть родителем'); //FormItem::text('position', 'Позиция в меню'); FormItem::text('alias', 'Алиас'); FormItem::text('menu_title', 'Заголовок меню'); FormItem::text('title', 'Заголовок'); FormItem::timestamp('published_at', 'Дата публикации'); //->seconds(true); FormItem::textarea('meta_title', 'Мета-тег Title')->attributes(['rows' => 4]); FormItem::textarea('meta_desc', 'Мета-тег Description')->attributes(['rows' => 4]); FormItem::textarea('meta_key', 'Мета-тег Keywords')->attributes(['rows' => 4]); FormItem::ckeditor('introtext', 'Краткое описание'); FormItem::ckeditor('content', 'Контент'); });
<?php \Admin::model('App\\Product')->title('Products')->alias('products')->display(function () { $display = AdminDisplay::datatablesAsync(); $display->columns([Column::checkbox(), Column::string('id')->label('#'), Column::string('title')->label('Загаловок'), Column::string('active_status')->label('Статус'), Column::string('publish')->label('Опубликован')]); return $display; })->createAndEdit(function () { $form = AdminForm::tabbed(); $form->items(['Main' => [FormItem::columns()->columns([[FormItem::text('title', 'Загаловок')->required()->unique(), FormItem::textarea('description', 'Описание')->required(), FormItem::timestamp('publish', 'Дата и время публикации')->defaultValue(Carbon\Carbon::now()), FormItem::icheckbox('active', 'Статус')->defaultValue(true), FormItem::text('rest', 'Остаток'), FormItem::text('price', 'Цена')], [FormItem::text('sort', 'сортировка'), FormItem::bsselect('user_id', 'Пользователь')->model('App\\User')->defaultValue(Sentinel::check()->id)->display('email'), FormItem::bsselect('catalog_id', 'Категоря')->model('App\\Catalog')->display('level_label')->disableSort()->required()]])], 'content' => [FormItem::markdown('content', 'Контент')], 'images' => [FormItem::images('gallery', 'Картинки')], 'files' => [FormItem::view('suroviy.soa_addon::admin.elfinder')]]); return $form; });
<?php Admin::model('App\\User')->title('Пользователи')->display(function () { $display = AdminDisplay::datatables(); $display->with(); $display->filters([]); $display->columns([Column::string('first_name')->label('First_name'), Column::string('email')->label('Email')]); return $display; })->createAndEdit(function () { $form = AdminForm::form(); $form->items([FormItem::text('email', 'Email'), FormItem::text('password', 'Password'), FormItem::timestamp('last_login', 'Last Login')->format('d.m.Y'), FormItem::text('first_name', 'First Name'), FormItem::text('last_name', 'Last Name'), FormItem::multiselect('theroles', 'Роли')->model('App\\Role')->display('name')]); return $form; });
<?php /* * Создание и редактирование статей. * Файл Post.php */ Admin::model('App\\Models\\Post')->title('Article')->filters(function () { ModelItem::filter('PostForId')->scope('PostForId')->title('От 3 до 5'); })->columns(function () { Column::string('link', 'Link'); Column::string('header', 'Header'); Column::string('article', 'Article'); Column::string('author', 'Author'); Column::string('created_at', 'Created_at'); Column::string('updated_at', 'Updated_at'); })->form(function () { FormItem::text('link', 'Link')->required(); FormItem::text('header', 'Header')->required(); FormItem::ckeditor('article', 'Article')->required(); FormItem::text('author', 'Author')->required(); FormItem::timestamp('created_at', 'Created_at')->required(); FormItem::timestamp('updated_at', 'Updated_at')->required(); });
<?php Admin::model('App\\Form')->title('Form Items')->display(function () { $display = AdminDisplay::table(); $display->columns([Column::string('id')->label('ID'), Column::string('title')->label('String'), Column::datetime('created_at')->label('Created At')->format('d.m.Y H:i:s')]); return $display; })->createAndEdit(function () { $form = AdminForm::form(); $form->items([FormItem::columns()->columns([[FormItem::text('title', 'FormItem::text')->defaultValue('default value')->required(), FormItem::textaddon('textaddon', 'FormItem::textaddon')->addon('$')->placement('after'), FormItem::checkbox('checkbox', 'FormItem::checkbox'), FormItem::date('date', 'FormItem::date')->format('d.m.Y'), FormItem::time('time', 'FormItem::time')->format('H:i:s')->seconds(true), FormItem::timestamp('timestamp', 'FormItem::timestamp')->format('d.m.Y g:i A')], [FormItem::select('select', 'FormItem::select')->options([1 => 'First', 2 => 'Second', 3 => 'Third'])->nullable(), FormItem::custom()->display(function ($instance) { return view('custom_form_item', compact('instance')); })->callback(function ($instance) { $instance->custom = \Carbon\Carbon::now(); })], [FormItem::image('image', 'FormItem::image'), FormItem::images('images', 'FormItem::images')]]), FormItem::columns()->columns([[FormItem::textarea('textarea', 'FormItem::textarea')], [FormItem::ckeditor('ckeditor', 'FormItem::ckeditor')]])]); return $form; });
<?php \Admin::model('App\\Post')->title('Posts')->alias('posts')->display(function () { $display = AdminDisplay::table(); $display->columns([Column::checkbox(), Column::string('id')->label('#'), Column::string('title')->label('Загаловок'), Column::string('active_status')->label('Статус'), Column::string('publish')->label('Опубликован')]); return $display; })->createAndEdit(function () { $form = AdminForm::tabbed(); $form->items(['Main' => [FormItem::columns()->columns([[FormItem::text('title', 'Загаловок')->required()->unique(), FormItem::textarea('description', 'Описание')->required(), FormItem::timestamp('publish', 'Дата и время публикации')->defaultValue(Carbon\Carbon::now()), FormItem::icheckbox('active', 'Статус')->defaultValue(true)], [FormItem::text('alias', 'Алиас')->unique(), FormItem::bsselect('user_id', 'Пользователь')->model('App\\User')->defaultValue(Sentinel::check()->id)->display('email'), FormItem::bsselect('category_id', 'Категоря')->model('App\\Category')->display('level_label')->disableSort()->required(), FormItem::image('image', 'Картинка')]])], 'content' => [FormItem::markdown('content', 'Контент')]]); return $form; });
<?php \Admin::model('App\\Landing')->title('Landing')->alias('landing')->display(function () { $display = AdminDisplay::table(); $display->with('blocks'); $display->columns([Column::checkbox(), Column::string('id')->label('#'), Column::string('title')->label('Загаловок'), Column::string('active_status')->label('Статус'), Column::custom()->label('Блоки')->callback(function ($instance) { return '<a href="/admin/landing-blocks?landing_id=' . $instance->id . '">Редактировать</a>'; })]); return $display; })->edit(function ($id) { $form = AdminForm::tabbed(); $fields = []; $fields['Main'] = [FormItem::columns()->columns([[FormItem::text('title', 'Загаловок')->required()->unique(), FormItem::textarea('description', 'Описание')->required(), FormItem::timestamp('publish', 'Дата и время публикации')->defaultValue(Carbon\Carbon::now()), FormItem::timestamp('publish_end', 'Дата и время олкончания публикация')->defaultValue(Carbon\Carbon::now()), FormItem::text('redirect', 'Редирект'), FormItem::icheckbox('active', 'Статус')->defaultValue(true)], [FormItem::text('alias', 'Алиас')->unique(), FormItem::text('name', 'Название')->required()->unique(), FormItem::image('image', 'Картинка')]])]; $model = App\Landing::find($id); if ($model) { $path = base_path('App/AdminLanding/' . $model->name . '.php'); if (is_file($path)) { $fields2 = (require_once $path); $fields = array_merge($fields, $fields2); } } $form->items($fields); return $form; })->create(function ($id) { $form = AdminForm::tabbed(); $fields = []; $fields['Main'] = [FormItem::columns()->columns([[FormItem::text('title', 'Загаловок')->required()->unique(), FormItem::textarea('description', 'Описание')->required(), FormItem::timestamp('publish', 'Дата и время публикации')->defaultValue(Carbon\Carbon::now()), FormItem::timestamp('publish_end', 'Дата и время олкончания публикация')->defaultValue(Carbon\Carbon::now()), FormItem::text('redirect', 'Редирект'), FormItem::icheckbox('active', 'Статус')->defaultValue(true)], [FormItem::text('alias', 'Алиас')->unique(), FormItem::text('name', 'Название')->required()->unique(), FormItem::image('image', 'Картинка')]])]; $form->items($fields); return $form; });
if ($instance->active) { return ' <span><i class="fa fa-chevron-down" data-toggle="tooltip" title="" data-original-title="Active"></i></span>'; } })->orderable(false)]); return $display; })->createAndEdit(function () { $form = AdminForm::form(); $form->ajax_validation(true); $form->items([FormItem::columns()->columns([[FormItem::text('lable', 'lable'), FormItem::bsselect('user_id', 'User')->model('App\\User')->display('email')->defaultValue(Sentinel::getUser()->id), FormItem::icheckbox('active')->label('Active')->skin('flat')], [FormItem::text('comment_id', 'Page ID'), FormItem::text('comment_type')]]), FormItem::ckeditor('content', 'Content')]); return $form; }); /** * Sitemaps */ Admin::model('App\\Sitemap')->title('Sitemap')->alias('sitemaps')->display(function () { $display = AdminDisplay::table(); $display->filters([Filter::field('loc')->title(function ($value) { return 'URL:' . $value; })]); $display->columns([Column::checkbox(), Column::string('loc')->label('loc'), Column::string('lastmod')->label('lastmod'), Column::string('changefreq')->label('changefreq'), Column::string('priority')->label('priority'), Column::string('updated_at')->label('updated_at'), Column::custom()->label('in_sitemap')->callback(function ($instance) { if ($instance->in_sitemap) { return ' <span><i class="fa fa-chevron-down" data-toggle="tooltip" title="" data-original-title="Active"></i></span>'; } })->orderable(false)]); return $display; })->createAndEdit(function () { $form = AdminForm::form(); $form->ajax_validation(true); $form->items([FormItem::columns()->columns([[FormItem::text('loc', 'loc')->required(), FormItem::timestamp('lastmod', 'lastmod')->required(), FormItem::select('changefreq', 'changefreq')->enum(['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'])->required(), FormItem::text('priority', 'priority')->required(), FormItem::icheckbox('in_sitemap')->label('In sitemap')]])]); return $form; });
<?php Admin::model('App\\Models\\Entry')->title('Entries')->display(function () { $display = AdminDisplay::datatables(); $display->with(); $display->filters([Filter::scope('published'), Filter::scope('unpublished')]); $display->columns([Column::string('title')->label('Title'), Column::string('content')->label('Content'), Column::datetime('published_at')->format('H:i d.m.Y')->label('Published At'), Column::custom()->label('Published')->callback(function ($instance) { return $instance->published ? '✓' : '-'; })]); return $display; })->createAndEdit(function () { $form = AdminForm::form(); $form->items([FormItem::text('title', 'Title')->required(), FormItem::text('slug', 'Slug')->required(), FormItem::checkbox('published', 'Published'), FormItem::timestamp('published_at', 'Published At')->format('d.m.Y H:i:s')->seconds(true), FormItem::ckeditor('content', 'Content')->required()]); return $form; });