本文整理汇总了PHP中Column::lists方法的典型用法代码示例。如果您正苦于以下问题:PHP Column::lists方法的具体用法?PHP Column::lists怎么用?PHP Column::lists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Column
的用法示例。
在下文中一共展示了Column::lists方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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\\Marker')->title('Маркеры')->display(function () {
$display = AdminDisplay::datatables();
$display->with('markerGroups');
$display->filters([]);
$display->columns([Column::string('name')->label('Имя'), Column::lists('markerGroups.name')->label('Входит в группы'), Column::image('ico')->label('Иконка')]);
return $display;
})->create(function () {
$form = AdminForm::form();
$form->items([FormItem::columns()->columns([[FormItem::text('name', 'Имя'), FormItem::image('ico', 'Иконка'), FormItem::checkbox('showadd', 'Показывать в форме добавления рецепта')->defaultValue(0), FormItem::text('sortorder', 'Порядок сортировки')], [FormItem::text('metakey', 'Meta Keywords'), FormItem::text('metadesk', 'Meta Description'), FormItem::text('slug', 'Slug (если пустое, генерируется реалтайм из имени)'), FormItem::text('title', 'Title')]])]);
return $form;
})->edit(function () {
$form = AdminForm::form();
$form->items([FormItem::columns()->columns([[FormItem::text('name', 'Имя'), FormItem::image('ico', 'Иконка'), FormItem::checkbox('showadd', 'Показывать в форме добавления рецепта'), FormItem::text('sortorder', 'Порядок сортировки')], [FormItem::text('metakey', 'Meta Keywords'), FormItem::text('metadesk', 'Meta Description'), FormItem::text('slug', 'Slug (если пустое, генерируется реалтайм из имени)'), FormItem::text('title', 'Title')]])]);
return $form;
});
示例3: 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);
示例4:
<?php
Admin::model('App\\MarkerGroup')->title('Группы маркеров')->display(function () {
$display = AdminDisplay::datatables();
$display->with('markers');
$display->filters([]);
$display->columns([Column::string('name')->label('Имя'), Column::string('id')->label('ID'), Column::lists('markers.name')->label('Маркеры')]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::text('name', 'Имя')->required(), FormItem::checkbox('showadd', 'Показывать в форме добавления рецепта'), FormItem::image('ico', 'Иконка'), FormItem::text('metakey', 'Meta Keywords'), FormItem::text('metadesk', 'Meta Description'), FormItem::multiselect('markers', 'Маркеры')->model('App\\Marker')->display('name')]);
return $form;
})->delete(function ($id) {
if (in_array($id, [1, 2, 3])) {
return null;
} else {
return 1;
}
});
示例5:
<?php
Admin::model('\\Company')->title('Companies')->with('contacts')->columns(function () {
Column::string('title', 'Title');
Column::string('address', 'Address');
Column::string('phone', 'Phone');
Column::lists('contacts.full_name', 'Contacts');
})->form(function () {
FormItem::text('title', 'Title')->required()->unique();
FormItem::text('address', 'Address');
FormItem::text('phone', 'Phone');
});
示例6:
<?php
Admin::model('republic\\Place')->async()->title('Места')->with('rest', 'city', 'cat', 'location', 'images')->columns(function () {
Column::string('place_id', '№');
Column::string('place_name', 'Название');
Column::string('place_desc', 'Описание');
Column::string('location.longitude', 'Долгота');
Column::string('location.latitude', 'Широта');
Column::string('city.city_name', 'Город');
Column::string('cat_for_app.cat_for_app_id', 'Категория');
Column::string('picture', 'Рисунок');
Column::lists('rest.rest_type', 'Вид отдыха');
Column::lists('images.image_src', 'Изображения');
})->columnFilter();
示例7: 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);
示例8:
<?php
Admin::model('App\\Product')->title('Productos')->display(function () {
$display = AdminDisplay::datatables();
$display->with('colors');
// $display->filters([
// ]);
$display->columns([Column::image('thumbnail')->label('Miniatura'), Column::string('title')->label('Título'), Column::lists('colors.name')]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::tabbed();
$form->items(['General' => [FormItem::text('title', 'Título'), FormItem::text('subtitle', 'Subtítulo'), FormItem::multiselect('colors', 'Colores')->model('App\\Color')->display('name'), FormItem::select('category_id', 'Categoria')->model('App\\Category')->display('name'), FormItem::text('tags', 'Serie')], 'Extra' => [FormItem::ckeditor('description', 'Descripcion'), FormItem::jsonField('specs', 'Especificaciones'), FormItem::ckeditor('details', 'Detalles')], 'Media' => [FormItem::image('thumbnail', 'Miniatura'), FormItem::images('images', 'Imagenes')], 'Venta' => [FormItem::text('price', 'Precio'), FormItem::text('link', 'Link a tienda nube')]]);
return $form;
});
示例9:
<?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');
});