本文整理汇总了PHP中Filter::related方法的典型用法代码示例。如果您正苦于以下问题:PHP Filter::related方法的具体用法?PHP Filter::related怎么用?PHP Filter::related使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filter
的用法示例。
在下文中一共展示了Filter::related方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
<?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;
});
示例2:
<?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;
});
示例3:
<?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);
示例4: 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);
示例5:
<?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;
});
示例6:
<?php
Admin::model('App\\News')->title('Noticias')->display(function () {
$display = AdminDisplay::datatables();
$display->with('gallery');
$display->filters([Filter::related('gallery_id')->model('App\\Gallery')]);
$display->columns([Column::image('thumbnail'), Column::string('title')->label('Title'), Column::string('short_text')->label('Short_text')]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::columns()->columns([[FormItem::text('title', 'Title'), FormItem::text('short_text', 'Shorttext'), FormItem::select('gallery_id', 'Galería')->model('App\\Gallery')->display('title'), FormItem::ckeditor('text', 'Text')], [FormItem::checkbox('pin', 'Destacada'), FormItem::image('thumbnail', 'Thumbnail')]])]);
return $form;
});