예제 #1
0
 /**
  * @param array $items from which to choose
  * @param bool $firstEmpty add empty first item to selectbox?
  * @param bool $translateItems translate all items in selectbox?
  */
 public function __construct(array $items = NULL, $firstEmpty = TRUE, $translateItems = TRUE)
 {
     $this->items = $items;
     $this->firstEmpty = $firstEmpty;
     $this->translateItems = $translateItems;
     parent::__construct();
 }
예제 #2
0
 public function __construct($operation, array $filters = array())
 {
     if (!in_array($operation, $this->operations)) {
         $operations = implode(', ', $this->operations);
         throw new \Exception("Invalid composite filter operation [{$operation}]. Expected one of: {$operations}");
     }
     $this->operation = $operation;
     foreach ($filters as $filter) {
         if (is_array($filter)) {
             $filter = ColumnFilter::fromArray($filter);
         }
         $this->add($filter);
     }
 }
예제 #3
0
<?php

/*
 * This is a simple example of the main features.
 * For full list see documentation.
 */
Admin::model('App\\Models\\Sector')->title('Sectors')->alias('sector')->display(function () {
    $display = AdminDisplay::datatablesAsync();
    $display->order([[0, 'asc']]);
    $display->columns([Column::string('id')->label('Id'), Column::string('name')->label('Name'), Column::datetime('created_at')->format('d-m-Y h:i:s')->label('Created'), Column::datetime('updated_at')->format('d-m-Y h:i:s')->label('Updated')]);
    $display->columnFilters([null, ColumnFilter::text()->placeholder('Name'), ColumnFilter::range()->from(ColumnFilter::date()->format('d.m.Y')->placeholder('From Date'))->to(ColumnFilter::date()->format('d.m.Y')->placeholder('To Date')), ColumnFilter::range()->from(ColumnFilter::date()->format('d.m.Y')->placeholder('From Date'))->to(ColumnFilter::date()->format('d.m.Y')->placeholder('To Date'))]);
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::text('name', 'Name')->required()]);
    return $form;
});
예제 #4
0
<?php

Admin::model('App\\UserProduct')->title('Юзер-Товар')->display(function () {
    $display = AdminDisplay::datatables();
    $display->columns([Column::string('id')->label('ID'), Column::string('user.name')->label('Юзер'), Column::string('product.title')->label('Товар'), Column::string('review')->label('Отзыв'), Column::string('status')->label('Статус'), Column::string('sum')->label('Сумма'), Column::string('created_at')->label('Дата'), Column::string('updated_at')->label('Обновлено')]);
    $display->columnFilters([null, ColumnFilter::text()->placeholder('Юзер'), null, null, null, null, ColumnFilter::range()->from(ColumnFilter::date()->format('d.m.Y')->placeholder('С'))->to(ColumnFilter::date()->format('d.m.Y')->placeholder('По')), null]);
    return $display;
})->edit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::select('user_id', 'Юзер')->model('App\\User')->display('name')->required(), FormItem::select('product_id', 'Товар')->model('App\\Product')->display('title')->required(), FormItem::text('review', 'Отзыв'), FormItem::select('status', 'Статус')->enum(['M', 'A', 'D', 'R'])->nullable()]);
    return $form;
})->create(function () {
    $form = AdminForm::form();
    $form->items([FormItem::select('user_id', 'Юзер')->model('App\\User')->display('name')->required(), FormItem::select('product_id', 'Товар')->model('App\\Product')->display('title')->required()]);
    return $form;
});
 public function __construct($filterName, array $values)
 {
     parent::__construct($filterName);
     $this->values = $values;
 }
예제 #6
0
<?php

Admin::model('App\\Product')->title('Товары')->display(function () {
    $display = AdminDisplay::datatables();
    $display->columns([Column::string('id')->label('ID'), Column::string('title')->label('Название'), Column::string('ym_url')->label('ЯМ ссылка')->append(Column::url('ym_url')), Column::image('image_url')->label('Ссылка на картинку')]);
    $display->columnFilters([null, ColumnFilter::text()->placeholder('Товар'), null, null]);
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::text('title', 'Название')->required(), FormItem::text('ym_url', 'ЯМ ссылка')->required(), FormItem::text('image_url', 'Ссылка на картинку')->required()]);
    return $form;
});
예제 #7
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 ? '&check;' : '-';
    }), 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
                }
            }
        }
    })]);
예제 #8
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;
});
예제 #9
0
<?php

/*
 * This is a simple example of the main features.
 * For full list see documentation.
 */
Admin::model('App\\Models\\Member')->title('Members')->alias('member')->display(function () {
    $display = AdminDisplay::datatablesAsync();
    $display->order([[0, 'asc']]);
    $display->columns([Column::checkbox(), Column::string('organization.name')->label('Organization'), Column::string('status')->label('Status'), Column::string('type')->label('Type'), Column::string('title')->label('Function'), Column::string('first_name')->label('Firstname'), Column::string('last_name')->label('Lastname'), Column::string('email')->label('Email'), Column::custom()->label('Enabled')->callback(function ($instance) {
        return $instance->is_enabled ? '&check;' : '-';
    }), Column::datetime('created_at')->format('d-m-Y h:i:s')->label('Created')]);
    $display->columnFilters([null, ColumnFilter::text()->placeholder('Organization'), null, null, null, null, null, ColumnFilter::text()->placeholder('Email'), null, ColumnFilter::range()->from(ColumnFilter::date()->format('d.m.Y')->placeholder('From Date'))->to(ColumnFilter::date()->format('d.m.Y')->placeholder('To Date'))]);
    return $display;
})->edit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::checkbox('is_enabled', 'Enabled'), FormItem::select('organization_id', 'Organization')->model('App\\Models\\Organization')->display('name'), FormItem::text('first_name', 'Firstname'), FormItem::text('last_name', 'Lastname'), FormItem::text('email', 'Email')->unique(), FormItem::text('phone', 'Phone'), FormItem::text('url', 'Website'), FormItem::text('title', 'Function'), FormItem::custom()->display(function ($instance) {
        return '<div class="form-group ">
                                <label for="key">Key</label><br/>
                                ' . $instance->key . '
                            </div>';
    }), FormItem::custom()->display(function ($instance) {
        return '<div class="form-group ">
                                <label for="key">Status</label><br/>
                                ' . $instance->status . '
                            </div>';
    }), FormItem::custom()->display(function ($instance) {
        return '<div class="form-group ">
                                <label for="key">Type</label><br/>
                                ' . $instance->type . '
                            </div>';
예제 #10
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();
예제 #11
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);