本文整理汇总了PHP中AdminDisplay::table方法的典型用法代码示例。如果您正苦于以下问题:PHP AdminDisplay::table方法的具体用法?PHP AdminDisplay::table怎么用?PHP AdminDisplay::table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdminDisplay
的用法示例。
在下文中一共展示了AdminDisplay::table方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: strlen
Admin::model('App\\News3')->title('News')->alias('news3')->display(function () {
$display = AdminDisplay::tabbed();
$display->tabs(function () {
$tabs = [];
$columns = [Column::string('title')->label('Title'), Column::datetime('date')->label('Date')->format('d.m.Y'), Column::custom()->label('Published')->callback(function ($instance) {
return $instance->published ? '✓' : '-';
})];
$main = AdminDisplay::table();
$main->columns($columns);
$tabs[] = AdminDisplay::tab($main)->label('Main')->active(true);
$withScope = AdminDisplay::table();
$withScope->scope('last');
$withScope->columns($columns);
$tabs[] = AdminDisplay::tab($withScope)->label('With Scope');
$otherColumns = AdminDisplay::table();
$otherColumns->apply(function ($query) {
$query->orderBy('title', 'asc');
});
$otherColumns->columns([Column::string('title')->label('Title'), Column::custom()->label('Title Length')->callback(function ($instance) {
return strlen($instance->title);
})]);
$tabs[] = AdminDisplay::tab($otherColumns)->label('Other Columns and Order');
$otherDisplay = Admin::model('App\\Page')->display();
$tabs[] = AdminDisplay::tab($otherDisplay)->label('Display from Other Model');
return $tabs;
});
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::text('title', 'Title')->required(), FormItem::date('date', 'Date')->required()->format('d.m.Y'), FormItem::checkbox('published', 'Published'), FormItem::ckeditor('text', 'Text')]);
示例2:
<?php
Admin::model('App\\About')->title('About')->display(function () {
$display = AdminDisplay::table();
$display->columns([Column::string('description')->label('description')]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::ckeditor('description', 'Description')->required()]);
return $form;
});
示例3:
<?php
Admin::model('App\\Post')->title('Posts (soft deletes)')->display(function () {
$display = AdminDisplay::tabbed();
$display->tabs(function () {
$tabs = [];
$default = AdminDisplay::table();
$default->columns([Column::string('title')->label('Title')]);
$tabs[] = AdminDisplay::tab($default)->label('Default')->active(true);
$withTrashed = AdminDisplay::table();
$withTrashed->scope('withTrashed');
$withTrashed->columns([Column::string('title')->label('Title')]);
$tabs[] = AdminDisplay::tab($withTrashed)->label('With Trashed');
$onlyTrashed = AdminDisplay::table();
$onlyTrashed->scope('onlyTrashed');
$onlyTrashed->columns([Column::string('title')->label('Title')]);
$tabs[] = AdminDisplay::tab($onlyTrashed)->label('Only Trashed');
return $tabs;
});
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::text('title', 'Title')->required()->unique(), FormItem::ckeditor('text', 'Text')]);
return $form;
});