本文整理汇总了PHP中Column::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP Column::filter方法的具体用法?PHP Column::filter怎么用?PHP Column::filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Column
的用法示例。
在下文中一共展示了Column::filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
<?php
Admin::model('\\Country')->title('Countries')->with('contacts')->columns(function () {
Column::string('title', 'Title');
Column::count('contacts', 'Contacts')->append(Column::filter('country_id')->model('\\Contact'));
})->form(function () {
FormItem::text('title', 'Title')->required()->unique();
});
示例2:
<?php
Admin::model(App\Models\Task::class)->title('Задачи')->with('subject')->filters(function () {
})->columns(function () {
Column::string('number_task', 'Number_task');
Column::image('image')->sortable(false);
Column::string('experience', 'Experience');
Column::string('gold', 'Gold');
Column::string('grade', 'Grade');
Column::string('subject.name', 'Subject')->append(Column::filter('subject_id')->value('subject_id'));
Column::string('answer', 'Answer');
Column::string('detail', 'detail');
Column::string('set_of_task', 'Set_of_task');
})->form(function () {
FormItem::text('number_task', 'Number Task');
FormItem::image('image', 'Image');
FormItem::text('experience', 'Experience');
FormItem::text('gold', 'Gold');
FormItem::text('grade', 'Grade');
FormItem::select('subject_id', 'Subject')->list(App\Models\Subject::class);
FormItem::text('answer', 'Answer');
FormItem::text('detail', 'detail');
FormItem::text('set_of_task', 'Set Of Task');
});
示例3:
<?php
/*
* This is a simple example of the main features.
* For full list see documentation.
*/
Admin::model('Crimibook\\Models\\Follow')->title('Users follows')->display(function () {
$display = AdminDisplay::datatables();
$display->with('users', 'userFollowsTo');
$display->filters([Filter::related('follower_id')->model('Crimibook\\User'), Filter::related('followed_id')->model('Crimibook\\User')]);
$display->columns([Column::string('users.name')->label('Follower Name')->append(Column::filter('follower_id')), Column::lists('userFollowsTo.name')->label('Follows To')->append(Column::filter('followed_id'))]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::select('follower_id', 'Follower Name')->model('Crimibook\\User')->display('name')->required(), FormItem::multiselect('userFollowsTo', 'Follow To')->model('Crimibook\\User')->display('name')]);
return $form;
});
示例4:
<?php
Admin::model('App\\Order')->title('Управление заказами')->display(function () {
$display = AdminDisplay::datatables();
$display->with('status');
$display->filters([Filter::related('order_status_id')->model('App\\OrderStatus')->display('title')]);
$display->columns([Column::string('id')->label('№'), Column::string('customer_name')->label('ФИО'), Column::string('phone')->label('Телефон'), Column::string('sum_order')->label('Сумма заказа'), Column::string('status.title')->label('Статус заказа')->append(Column::filter('order_status_id')), Column::action('show')->label('Подробности')->icon('fa fa-share')->url('order_content/:id')]);
return $display;
})->delete(null);
示例5:
<?php
Admin::model(App\Product::class)->title('Управление товарами')->display(function () {
$display = AdminDisplay::datatables();
$display->with('category');
$display->filters([Filter::related('category_id')->model(App\Category::class)]);
$display->columns([Column::string('name')->label('Название'), Column::string('price')->label('Цена'), Column::image('image')->label('Изображение'), Column::string('category.title')->label('Категория')->append(Column::filter('category_id')), Column::custom()->label('Топ')->callback(function ($instance) {
return $instance->active ? 'да' : 'нет';
}), Column::string('product_rest')->label('Остаток')]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::text('name', 'Название'), FormItem::text('slug', 'Slug'), FormItem::text('price', 'Цена'), FormItem::image('image', 'Изображение'), FormItem::select('category_id', 'Категория')->model(App\Category::class)->display('title'), FormItem::checkbox('active', 'Топ'), FormItem::ckeditor('description', 'Описание'), FormItem::text('product_rest', 'Количество товара')->defaultValue('0')]);
return $form;
});
示例6:
<?php
/*
* This is a simple example of the main features.
* For full list see documentation.
*/
Admin::model('Crimibook\\Models\\Album')->title('Albums')->display(function () {
$display = AdminDisplay::datatables();
$display->with('owner');
$display->filters([Filter::related('user_id')->model('Crimibook\\User')]);
$display->columns([Column::string('name')->label('Name'), Column::string('description')->label('Description'), Column::string('owner.name')->label('Owner')->append(Column::filter('user_id'))]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::text('name', 'Name')->required(), FormItem::text('description', 'Description')->required(), FormItem::select('user_id', 'User')->model('Crimibook\\User')->display('name')->required()]);
return $form;
});
示例7: use
<?php
Admin::model('App\\Contact3')->title('Contact')->alias('contacts3')->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 ($id) {
$display = AdminDisplay::tabbed();
$display->tabs(function () use($id) {
$tabs = [];
$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')]])]);
$tabs[] = AdminDisplay::tab($form)->label('Main Form')->active(true);
if (!is_null($id)) {
$instance = App\Contact::find($id);
if ($instance->country_id) {
$country = Admin::model('App\\Country')->fullEdit($instance->country_id);
$tabs[] = AdminDisplay::tab($country)->label('Form from Related Model (Country)');
}
$companies = Admin::model('App\\Company')->display();
$companies->scope('withContact', $id);
$companies->parameters(['contact_id' => $id]);
$tabs[] = AdminDisplay::tab($companies)->label('Display from Related Model (Companies)');
}
return $tabs;
});
return $display;
})->delete(null);
示例8:
<?php
Admin::model('App\\Country')->title('Countries (orderable)')->display(function () {
$display = AdminDisplay::table();
$display->apply(function ($query) {
$query->orderBy('order', 'asc');
});
$display->columns([Column::string('title')->label('Title'), Column::count('contacts')->label('Contacts')->append(Column::filter('country_id')->model('App\\Contact')), Column::order()]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::text('title', 'Title')->required()->unique()]);
return $form;
});
示例9:
<?php
Admin::model(App\PedidoLinea::class)->title('Líneas Pedido')->with()->filters(function () {
ModelItem::filter('pedido_id')->as('pedido')->title()->from(App\Pedido::class, 'id');
})->columns(function () {
Column::string('id', 'Id');
Column::string('pedido_id', 'Pedido')->append(Column::filter('pedido')->value('pedido_id'));
Column::string('codigo', 'Cod.');
Column::string('descripcion', 'Item');
Column::string('precio', 'Precio');
Column::string('cantidad', 'Cant.');
Column::string('subtotal', 'Importe');
});
示例10:
<?php
Admin::model(App\Models\Subject::class)->title('Темы')->with('category')->filters(function () {
ModelItem::filter('category_id')->title()->from('App\\Models\\Category_Subject', 'name');
})->columns(function () {
Column::string('name', 'Name_subject');
//category.name обращение к методу category в модели Category_Subject с добавлением фильтра по category_id выборка из Category_Subject
Column::string('category.name', 'Category_Subject')->append(Column::filter('category_id')->value('category_id'));
Column::string('code', 'Code');
})->form(function () {
FormItem::text('name', 'Name Subject');
FormItem::select('category_id', 'Category')->list(App\Models\Category_Subject::class);
FormItem::text('code', 'Code');
});
示例11:
<?php
Admin::model(App\Pedido::class)->title('Pedidos')->with()->filters(function () {
ModelItem::filter('user_id')->as('cliente')->title()->from(App\User::class, 'razsoc');
})->columns(function () {
Column::string('id', 'Id');
Column::string('user.razsoc', 'Cliente')->append(Column::filter('cliente')->value('user_id'));
Column::string('total', 'Total');
Column::string('created_at', 'Fecha');
Column::Estado('estado', 'Estado')->sortable(false);
Column::action('show', 'Detalle')->icon('fa-list')->style('short')->url('pedido_lineas?pedido=:id');
})->form(function () {
FormItem::text('id', 'Id')->attributes(["readonly" => "readonly"]);
FormItem::select('user_id', 'Cliente')->list('App\\User')->attributes(["disabled" => "true"]);
FormItem::text('total', 'Total')->attributes(["readonly" => "readonly"]);
FormItem::text('created_at', 'Fecha')->attributes(["readonly" => "readonly"]);
FormItem::select('estado', 'Estado')->list(['P' => 'Pendiente', 'I' => 'Ingresado', 'C' => 'Cancelado']);
});
示例12:
<?php
/*
* This is a simple example of the main features.
* For full list see documentation.
*/
Admin::model('Crimibook\\Models\\Status')->title('Status')->display(function () {
$display = AdminDisplay::datatables();
$display->with();
$display->filters([Filter::related('user_id')->model('Crimibook\\User')]);
$display->columns([Column::string('users.name')->label('Owner')->append(Column::filter('user_id')), Column::string('body')->label('Text'), Column::string('image_path')->label('Photo path'), Column::image('image_path')->label('Photo')]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::select('user_id', 'User')->model('Crimibook\\User')->display('name')->required(), FormItem::text('body', 'Body')->required(), FormItem::text('image_path', 'Photo')]);
return $form;
});
示例13: dd
<?php
Admin::model('App\\Contact')->title('Contacts')->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<br/><small>(image)</small>'), Column::string('fullName')->label('Name<br/><small>(string with accessor)</small>'), Column::datetime('birthday')->label('Birthday<br/><small>(datetime)</small>')->format('d.m.Y'), Column::string('country.title')->label('Country<br/><small>(string from related model)</small>')->append(Column::filter('country_id')), Column::count('companies')->label('Companies<br/><small>(count)</small>'), Column::lists('companies.title')->label('Companies<br/><small>(lists)</small>'), Column::custom()->label('Has Photo?<br/><small>(custom)</small>')->callback(function ($instance) {
return $instance->photo ? '✓' : '-';
}), Column::action('my_action')->label('<small>(action)</small>')->value('Custom action')->target('_blank')->callback(function ($instance) {
dd('Custom action called with instance:', $instance->toArray());
})]);
return $display;
})->createAndEdit(null)->delete(null);
示例14:
<?php
Admin::model(App\User::class)->title('Troops')->with()->filters(function () {
ModelItem::filter('status')->title('with status filter');
})->columns(function () {
Column::string('id', 'Troop');
Column::string('name', 'Coordinator');
Column::string('email', 'Email');
Column::string('program_level', 'Program Level');
Column::active('status', 'Status')->append(Column::filter('status')->value('status'));
})->form(function () {
FormItem::text('id', 'Troop Number')->unique()->required();
FormItem::text('name', 'Coordinator');
FormItem::text('email', 'Email')->unique()->required();
FormItem::text('phone', 'Phone');
FormItem::text('num_girls', 'Number of Girls');
FormItem::select('program_level', 'Program Level')->enum(['Brownie', 'Junior', 'Cadette', 'Senior', 'Ambassador']);
FormItem::select('weekend', 'Weekend only?')->list([1 => 'Yes', 0 => 'No']);
FormItem::checkbox('status', 'Active?')->required();
});
示例15:
<?php
Admin::model('\\Contact')->title('Contacts')->with('country', 'companies')->filters(function () {
ModelItem::filter('country_id')->title()->from('\\Country');
ModelItem::filter('withoutCompanies')->scope('withoutCompanies')->title('without companies');
})->columns(function () {
Column::image('photo');
Column::string('full_name', 'Name')->orderBy('lastName')->sortableDefault();
Column::date('birthday', 'Birthday')->format('medium', 'none');
Column::string('country.title', 'Country')->append(Column::filter('country_id')->value('country.id'));
Column::lists('companies.title', 'Companies');
Column::action('show', 'Custom action')->target('_blank')->icon('fa-globe')->style('long')->callback(function ($instance) {
echo 'You are trying to call custom action "show" with row id "' . $instance->id . '"';
die;
});
})->form(function () {
FormItem::text('firstName', 'First Name')->required();
FormItem::text('lastName', 'Last Name')->required();
FormItem::image('photo', 'Photo');
FormItem::date('birthday', 'Birthday');
FormItem::text('phone', 'Phone');
FormItem::text('address', 'Address');
FormItem::select('country_id', 'Country')->list('\\Country')->required();
FormItem::multiSelect('companies', 'Companies')->list('\\Company')->value('companies.company_id');
FormItem::ckeditor('comment', 'Comment');
FormItem::view('admin.form.comment');
});