예제 #1
0
/*
 * This is a simple example of the main features.
 * For full list see documentation.
 */
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Input;
use App\Product;
use App\UserProduct;
Admin::model('App\\User')->title('Пользователи')->display(function () {
    $display = AdminDisplay::datatables();
    $display->columns([Column::checkbox(), Column::string('id')->label('ID'), Column::string('name')->label('Имя'), Column::custom()->label('Актив.')->callback(function ($instance) {
        return $instance->is_active ? '✓' : '-';
    }), Column::string('email')->label('Email'), Column::count('products')->label('Товаров')->orderable(true), Column::count('list_active_products')->label('Акт. товаров')->orderable(true), Column::string('balance')->label('Баланс')]);
    $display->columnFilters([null, ColumnFilter::select()->model('App\\User')->display('name'), null, null, null, null]);
    $display->actions([Column::action('export')->value('Раздать товары')->icon('fa-share')->callback(function ($collection) {
        $max_products_per_user = config('main.max_products_per_user', 3);
        foreach ($collection as $key => $user) {
            $active_products = $user->list_active_products;
            $count_active_products = count($active_products);
            if ($count_active_products >= 0 && $count_active_products < $max_products_per_user) {
                $random_product = Product::orderByRaw("RAND()")->first();
                try {
                    $user_product = UserProduct::create(['user_id' => $user->id, 'product_id' => $random_product->id]);
                } catch (QueryException $e) {
                    //Nothing
                }
            }
        }
    })]);
예제 #2
0
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->ajax_validation(true);
    $form->horizontal(true);
    $form->label_size('col-sm-offset-4 col-sm-1');
    $form->field_size('col-sm-3');
    $form->items([FormItem::text('lable', 'Lable')->required(), FormItem::text('url', 'URL'), FormItem::text('name')->label('Name'), FormItem::text('accesskey')->label('Accesskey'), FormItem::text('tabindex')->label('Tabindex'), FormItem::checkbox('active')->label('Active')]);
    return $form;
});
/**
 * Page
 */
Admin::model('App\\Page')->title('Pages')->alias('pages')->display(function () {
    $display = AdminDisplay::datatables();
    $display->with('fields');
    $display->columnFilters([null, null, null, null, ColumnFilter::select()->placeholder('all')->model('App\\PAge')->display('context')]);
    $display->columns([Column::checkbox(), Column::string('id')->label('#'), Column::string('title')->label('Title'), Column::string('alias')->label('Alias'), Column::string('context')->label('Context'), Column::custom()->label('Active')->callback(function ($instance) {
        return $instance->active ? '&check;' : '-';
    })]);
    return $display;
})->create(function ($id) {
    $form = AdminForm::form();
    $form->ajax_validation(true);
    $form->horizontal(true);
    $form->label_size('col-sm-offset-4 col-sm-1');
    $form->field_size('col-sm-3');
    $form->items([FormItem::text('title', 'Title')->validationRules('unique:pages,title,' . $id), FormItem::text('alias', 'Alias')->validationRules('unique:pages,alias,' . $id . ',id,context,' . Request::get('context', '')), FormItem::select('context', 'Context')->enum(config('jetcms.models.context')), FormItem::bsselect('user_id', 'User')->model('App\\User')->display('email|id')->defaultValue(Sentinel::check()->id)->nullable()]);
    return $form;
})->edit(function ($id) {
    $model = App\Page::find($id);
    $form = AdminForm::tabbed();
예제 #3
0
파일: Page.php 프로젝트: stcoder/uf-vova
<?php

/**
 * @var \SleepingOwl\Admin\Model\ModelConfiguration
 */
$model = Admin::model(\App\Page::class);
$model->title('Страницы');
$model->display(function () {
    $display = AdminDisplay::datatables();
    $display->filters([Filter::field('id')->title(function ($value) {
        return 'Выбрана страница с идентификатором: ' . $value;
    })]);
    $display->columns([Column::string('title')->label('Заголовок'), Column::published('published')->label('Опубликован')->orderable(false), Column::datetime('created_at')->label('Создан')->format('d.m.Y в H:i')]);
    $display->columnFilters([null, ColumnFilter::select()->options(['нет' => 'Нет', 'да' => 'Да'])->filter_field('published')]);
    return $display;
})->createAndEdit(function ($id) use($model) {
    $model->title($id ? 'Редактировать страницу' : 'Создать страницу');
    $form = AdminForm::tabbed();
    $form->items(['Основное' => [FormItem::text('title', 'Заголовок')->required(), FormItem::checkbox('published', 'Опубликовать'), FormItem::ckeditor('content', 'Содержимое')], 'Мета данные' => [FormItem::textarea('meta_keywords', 'Ключевые слова')->rows(2), FormItem::textarea('meta_description', 'Описание страницы')->rows(4), FormItem::textarea('meta_others', 'Другая мета информация')->rows(7)]]);
    return $form;
});
예제 #4
0
<?php

Admin::model('App\\Contact4')->title('Contact')->alias('contacts4')->display(function () {
    $display = AdminDisplay::datatables();
    $display->with('country', 'companies');
    $display->filters([Filter::related('country_id')->model('App\\Country')]);
    $display->order([[1, 'asc']]);
    $display->columns([Column::image('photo')->label('Photo'), Column::string('fullName')->label('Name'), Column::string('height')->label('Height'), 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')]);
    $display->columnFilters([null, ColumnFilter::text()->placeholder('Full Name'), ColumnFilter::range()->from(ColumnFilter::text()->placeholder('From'))->to(ColumnFilter::text()->placeholder('To')), ColumnFilter::range()->from(ColumnFilter::date()->placeholder('From Date')->format('d.m.Y'))->to(ColumnFilter::date()->placeholder('To Date')->format('d.m.Y')), ColumnFilter::select()->placeholder('Country')->model('\\App\\Country')->display('title'), ColumnFilter::text()->placeholder('Companies')]);
    return $display;
})->createAndEdit(function ($id) {
    return null;
})->delete(null);