本文整理汇总了PHP中Column::checkbox方法的典型用法代码示例。如果您正苦于以下问题:PHP Column::checkbox方法的具体用法?PHP Column::checkbox怎么用?PHP Column::checkbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Column
的用法示例。
在下文中一共展示了Column::checkbox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: use
<?php
/** @var \SleepingOwl\Admin\Model\ModelConfiguration $model */
$model = Admin::model(\App\HistoryEvent::class);
$model->title('История – события');
$model->display(function () {
$display = AdminDisplay::datatables();
$display->with('date');
$display->columns([Column::checkbox(), Column::string('date.title')->label('Дата'), Column::custom()->label('Заголовок')->callback(function ($instance) {
$res = $instance->title;
if ($instance->more) {
$res .= '<br><div class="label label-primary">Кнопка – подробней</div>';
}
return $res;
}), Column::datetime('date_event')->format('d.m.Y')->label('Точная дата события'), Column::datetime('created_at')->label('Создан')->format('d.m.Y в H:i')]);
$display->apply(function (\Illuminate\Database\Eloquent\Builder $query) {
$query->withTrashed();
});
return $display;
})->createAndEdit(function ($id) use($model) {
$model->title($id ? 'Редактировать событие' : 'Создать событие');
$form = AdminForm::form();
$form->items([FormItem::text('title', 'Заголовок'), FormItem::image('image', 'Картинка'), FormItem::select('history_date_id', 'Дата')->model(\App\HistoryDate::class)->display('title')->required(), FormItem::ckeditor('description', 'Описание')->required(), FormItem::date('date_event', 'Точная дата события'), FormItem::checkbox('more', 'Показать кнопку – подробней')]);
return $form;
});
示例2:
<?php
\Admin::model('App\\Product')->title('Products')->alias('products')->display(function () {
$display = AdminDisplay::datatablesAsync();
$display->columns([Column::checkbox(), Column::string('id')->label('#'), Column::string('title')->label('Загаловок'), Column::string('active_status')->label('Статус'), Column::string('publish')->label('Опубликован')]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::tabbed();
$form->items(['Main' => [FormItem::columns()->columns([[FormItem::text('title', 'Загаловок')->required()->unique(), FormItem::textarea('description', 'Описание')->required(), FormItem::timestamp('publish', 'Дата и время публикации')->defaultValue(Carbon\Carbon::now()), FormItem::icheckbox('active', 'Статус')->defaultValue(true), FormItem::text('rest', 'Остаток'), FormItem::text('price', 'Цена')], [FormItem::text('sort', 'сортировка'), FormItem::bsselect('user_id', 'Пользователь')->model('App\\User')->defaultValue(Sentinel::check()->id)->display('email'), FormItem::bsselect('catalog_id', 'Категоря')->model('App\\Catalog')->display('level_label')->disableSort()->required()]])], 'content' => [FormItem::markdown('content', 'Контент')], 'images' => [FormItem::images('gallery', 'Картинки')], 'files' => [FormItem::view('suroviy.soa_addon::admin.elfinder')]]);
return $form;
});
示例3:
<?php
\Admin::model('App\\LandingBlocks')->title('Landing blocks')->alias('landing-blocks')->display(function () {
$display = AdminDisplay::table();
$display->apply(function ($query) {
$query->orderBy('order', 'ASC');
});
$display->columns([Column::checkbox(), Column::string('id')->label('#'), Column::string('label')->label('Загаловок'), Column::order()]);
return $display;
})->edit(function ($id) {
$form = AdminForm::tabbed();
$fields = [];
$fields['Main'] = [FormItem::columns()->columns([[FormItem::text('label', 'Загаловок')->required()->unique(), FormItem::textarea('description', 'Описание'), FormItem::text('class', 'Класс'), FormItem::icheckbox('active', 'Статус')->defaultValue(true)], [FormItem::text('name', 'Имя блока')->required(), FormItem::text('landing_id', 'Landing')]])];
$model = App\LandingBlocks::find($id);
if ($model) {
$path = base_path('App' . DIRECTORY_SEPARATOR . 'AdminLanding' . DIRECTORY_SEPARATOR . str_replace('.', DIRECTORY_SEPARATOR, $model->name) . '.php');
if (is_file($path)) {
$fields2 = (require_once $path);
$fields = array_merge($fields, $fields2);
}
}
$form->items($fields);
return $form;
})->create(function ($id) {
$form = AdminForm::tabbed();
$fields = [];
$fields['Main'] = [FormItem::columns()->columns([[FormItem::text('label', 'Загаловок')->required()->unique(), FormItem::textarea('description', 'Описание')->required(), FormItem::text('class', 'Класс'), FormItem::icheckbox('active', 'Статус')->defaultValue(true)], [FormItem::text('name', 'Имя блока')->required(), FormItem::text('landing_id', 'Landing')]])];
$form->items($fields);
return $form;
});
示例4: foreach
$mainDisplay->actions([Column::action('post_import')->value('Импортировать последние 10 записей')->icon('fa-share')->callback(function ($collection) {
\App\Imports\Post::import(0, 10);
}), Column::action('post_trashed')->value('Удалить записи')->icon('fa-times')->callback(function (\Illuminate\Database\Eloquent\Collection $collections) {
if ($collections) {
/** @var \App\Post $collection */
foreach ($collections as $collection) {
$collection->delete();
}
}
})]);
$mainDisplay->order([3, 'desc']);
$secondaryDisplay = AdminDisplay::datatables();
$secondaryDisplay->apply(function ($query) {
$query->onlyTrashed();
});
$secondaryDisplay->columns([Column::checkbox(), Column::string('id'), Column::custom()->label('Картинка')->callback(function ($instance) {
$attachment = $instance->attachments()->first();
if (!is_null($attachment)) {
if ($attachment->type === 'album') {
$attachment = $attachment->childs()->first();
}
return "<img class='thumbnail' width='80px' src='{$attachment->srcs['image_small']}'>";
}
return '';
}), Column::custom()->label('Текст')->callback(function ($instance) {
return str_limit($instance->text, 180);
}), Column::datetime('date')->label('Создан')->format('d.m.Y в H:i'), Column::datetime('created_at')->label('Импортирован')->format('d.m.Y в H:i'), Column::datetime('deleted_at')->label('Удален')->format('d.m.Y в H:i')]);
$secondaryDisplay->actions([Column::action('post_restore')->value('Восстановить записи')->icon('fa-refresh')->callback(function (\Illuminate\Database\Eloquent\Collection $collections) {
if ($collections) {
/** @var \App\Post $collection */
foreach ($collections as $collection) {
示例5: implode
<?php
\Admin::model('SleepingOwl\\Admin\\Model\\User')->title('admin::lang.menu.user.users')->alias('users')->display(function () {
$display = AdminDisplay::datatables();
$display->with('roles');
$display->columns([Column::checkbox(), Column::string('id')->label('#'), Column::custom()->label('Name')->callback(function ($instance) {
return $instance->first_name . ' ' . $instance->last_name;
}), Column::string('email')->label('Email'), Column::custom()->label('Roles')->callback(function ($instance) {
$user_roles = $instance->roles->lists('name');
$str_roles = implode("<br>", $user_roles->toArray());
$tooltip = '<a data-toggle="tooltip" data-html="true" data-placement="top" title="' . $str_roles . '">Show all Roles</button>';
$hidden_roles = '<span style="display:none;">' . $str_roles . '</span>';
return $user_roles->count() > 0 ? $tooltip . $hidden_roles : '';
}), Column::custom()->label('Custom Permissions')->callback(function ($instance) {
return count($instance->permissions) > 0 ? 'Yes' : 'No';
})]);
return $display;
})->createAndEdit(function ($id) {
$form = AdminForm::tabbed();
/**
* Fix
*/
if (is_null($id)) {
$form->storable(false);
$form->event_handler('SleepingOwl\\Admin\\Events\\UserEvent');
$password = FormItem::password('password', 'Password')->sentinel()->required();
} else {
$password = FormItem::password('password', 'Password')->sentinel();
}
$form->items(['Details' => [FormItem::text('first_name', 'Firstname')->required(), FormItem::text('last_name', 'Lastname')->required(), FormItem::text('email', 'Email')->required()->unique(), FormItem::sentinelpassword('password', 'Password'), FormItem::image('avatar', 'Avatar')], 'Roles & Permissions' => [FormItem::roles('roles', 'Roles')->model('Cartalyst\\Sentinel\\Roles\\EloquentRole')->display('name'), FormItem::permissions('permissions', 'Permissions')->inherited()], 'User Settings' => [FormItem::custom()->display(function ($instance) {
$skins = ['blue' => 'Blue', 'blue-light' => 'Blue Light', 'black' => 'Black', 'black-light' => 'Black Light', 'purple' => 'Purple', 'purple-light' => 'Purple Light', 'green' => 'Green', 'green-light' => 'Green Light', 'red' => 'Red', 'red-light' => 'Red Light', 'yellow' => 'Yellow', 'yellow-light' => 'Yellow Light'];
示例6: use
<?php
/** @var \SleepingOwl\Admin\Model\ModelConfiguration $model */
$model = Admin::model(\App\HistoryDate::class);
$model->title('История – даты');
$model->display(function () {
$display = AdminDisplay::datatables();
$display->columns([Column::checkbox(), Column::string('title')->label('Заголовок')->orderable(false), Column::string('description')->label('Описание')->orderable(false), Column::count('events')->label('Событий')->orderable(false), Column::datetime('created_at')->label('Создан')->format('d.m.Y в H:i')->orderable(false), Column::order()->orderable(false)]);
$display->order([[5, 'asc']]);
$display->apply(function (\Illuminate\Database\Eloquent\Builder $query) {
$query->withTrashed();
});
return $display;
})->createAndEdit(function ($id) use($model) {
$model->title($id ? 'Редактировать дату' : 'Создать дату');
$form = AdminForm::form();
$form->items([FormItem::text('title', 'Заголовок')->required(), FormItem::text('description', 'Описание')]);
return $form;
});
示例7: dd
<?php
Admin::model('App\\News8')->title('News (bulk actions)')->alias('news8')->display(function () {
$display = AdminDisplay::table();
$display->actions([Column::action('export')->value('Export')->icon('fa-share')->target('_blank')->callback(function ($collection) {
dd('You are trying to export:', $collection->toArray());
})]);
$display->columns([Column::checkbox(), Column::string('title')->label('Title'), Column::datetime('date')->label('Date')->format('d.m.Y'), Column::custom()->label('Published')->callback(function ($instance) {
return $instance->published ? '✓' : '-';
})]);
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')]);
return $form;
});
示例8:
<?php
\Admin::model('SleepingOwl\\Admin\\Model\\Permission')->title('Permissions')->alias('permissions')->display(function () {
$display = AdminDisplay::datatables();
$display->columns([Column::checkbox(), Column::string('id')->label('#'), Column::string('value')->label('Permission'), Column::string('description')->label('Description')]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::text('value', 'Permission')->required()->unique(), FormItem::text('description', 'Description')->required()]);
return $form;
});
示例9: config
<?php
/*
* 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 ? '✓' : '-';
}), 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
}
}
}
示例10: foreach
$mainDisplay->actions([Column::action('review_import')->value('Импортировать записи')->icon('fa-share')->callback(function (\Illuminate\Database\Eloquent\Collection $collection) {
\App\Imports\Review::import(0, 100);
}), Column::action('review_trashed')->value('Удалить записи')->icon('fa-times')->callback(function (\Illuminate\Database\Eloquent\Collection $collections) {
if ($collections) {
/** @var \App\Post $collection */
foreach ($collections as $collection) {
$collection->delete();
}
}
})]);
$secondaryDisplay = AdminDisplay::datatables();
$secondaryDisplay->apply(function ($query) {
$query->onlyTrashed();
});
$secondaryDisplay->with('profile');
$secondaryDisplay->columns([Column::checkbox(), Column::custom()->label('Автор')->callback(function ($instance) {
$fullName = '<p class="small text-center">' . $instance->profile->first_name . ' ' . $instance->profile->last_name . '</p>';
$img = '';
if (!is_null($instance->profile->photo)) {
$img = "<img class='thumbnail' width='110px' src='{$instance->profile->photo}'>";
}
return $img . $fullName;
}), Column::custom()->label('Текст')->callback(function ($instance) {
return str_limit($instance->text, 180);
}), Column::datetime('date')->label('Опубликован')->format('d.m.Y в H:i'), Column::datetime('created_at')->label('Импортирован')->format('d.m.Y в H:i'), Column::datetime('deleted_at')->label('Удален')->format('d.m.Y в H:i')]);
$secondaryDisplay->order([2, 'desc']);
$secondaryDisplay->actions([Column::action('review_import')->value('Импортировать записи')->icon('fa-share')->callback(function (\Illuminate\Database\Eloquent\Collection $collection) {
\App\Imports\Review::import(0, 100);
}), Column::action('review_restore')->value('Восстановить записи')->icon('fa-refresh')->callback(function (\Illuminate\Database\Eloquent\Collection $collections) {
if ($collections) {
/** @var \App\Post $collection */
示例11:
<?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 ? '✓' : '-';
}), 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>';
示例12:
<?php
/*
* This is a simple example of the main features.
* For full list see documentation.
*/
Admin::model('App\\Models\\Organization')->title('Organizations')->alias('organization')->display(function () {
$display = AdminDisplay::datatablesAsync();
$display->order([[0, 'asc']]);
$display->columns([Column::checkbox(), Column::string('sector.name')->label('Sector'), Column::string('status')->label('Status'), Column::string('name')->label('Name'), Column::string('kvk')->label('Kvk number'), Column::string('url')->label('Website'), Column::custom()->label('Enabled')->callback(function ($instance) {
return $instance->is_enabled ? '✓' : '-';
}), Column::datetime('created_at')->format('d-m-Y h:i:s')->label('Created')]);
$display->columnFilters([null, ColumnFilter::text()->placeholder('Sector'), ColumnFilter::text()->placeholder('Name'), null, null, null, 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('sector_id', 'Sector')->model('App\\Models\\Sector')->display('name'), FormItem::text('name', 'Name')->required(), FormItem::text('kvk', 'Kvk Number')->unique(), FormItem::text('phone', 'Phone'), FormItem::text('email', 'Email'), FormItem::text('url', 'Website'), FormItem::custom()->display(function ($instance) {
return '<div class="form-group ">
<label for="key">Address</label><br/>
' . $instance->locations->first()->location->street . '
</div>';
}), FormItem::custom()->display(function ($instance) {
return '<div class="form-group ">
<label for="key">Zipcode</label><br/>
' . $instance->locations->first()->location->postal_code . '
</div>';
}), FormItem::custom()->display(function ($instance) {
return '<div class="form-group ">
<label for="key">City</label><br/>
' . $instance->locations->first()->location->city . '
</div>';
示例13:
<?php
\Admin::model('Cartalyst\\Sentinel\\Roles\\EloquentRole')->title('Roles')->alias('roles')->display(function () {
$display = AdminDisplay::table();
$display->columns([Column::checkbox(), Column::string('id')->label('#'), Column::string('name')->label('Name'), Column::string('slug')->label('Slug')]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::tabbed();
$form->items(['Details' => [FormItem::text('name', 'Name')->required(), FormItem::text('slug', 'Slug')->required()->unique()], 'Permissions' => [FormItem::permissions('permissions', 'Permissions')]]);
return $form;
});
示例14:
<?php
\Admin::model('App\\Landing')->title('Landing')->alias('landing')->display(function () {
$display = AdminDisplay::table();
$display->with('blocks');
$display->columns([Column::checkbox(), Column::string('id')->label('#'), Column::string('title')->label('Загаловок'), Column::string('active_status')->label('Статус'), Column::custom()->label('Блоки')->callback(function ($instance) {
return '<a href="/admin/landing-blocks?landing_id=' . $instance->id . '">Редактировать</a>';
})]);
return $display;
})->edit(function ($id) {
$form = AdminForm::tabbed();
$fields = [];
$fields['Main'] = [FormItem::columns()->columns([[FormItem::text('title', 'Загаловок')->required()->unique(), FormItem::textarea('description', 'Описание')->required(), FormItem::timestamp('publish', 'Дата и время публикации')->defaultValue(Carbon\Carbon::now()), FormItem::timestamp('publish_end', 'Дата и время олкончания публикация')->defaultValue(Carbon\Carbon::now()), FormItem::text('redirect', 'Редирект'), FormItem::icheckbox('active', 'Статус')->defaultValue(true)], [FormItem::text('alias', 'Алиас')->unique(), FormItem::text('name', 'Название')->required()->unique(), FormItem::image('image', 'Картинка')]])];
$model = App\Landing::find($id);
if ($model) {
$path = base_path('App/AdminLanding/' . $model->name . '.php');
if (is_file($path)) {
$fields2 = (require_once $path);
$fields = array_merge($fields, $fields2);
}
}
$form->items($fields);
return $form;
})->create(function ($id) {
$form = AdminForm::tabbed();
$fields = [];
$fields['Main'] = [FormItem::columns()->columns([[FormItem::text('title', 'Загаловок')->required()->unique(), FormItem::textarea('description', 'Описание')->required(), FormItem::timestamp('publish', 'Дата и время публикации')->defaultValue(Carbon\Carbon::now()), FormItem::timestamp('publish_end', 'Дата и время олкончания публикация')->defaultValue(Carbon\Carbon::now()), FormItem::text('redirect', 'Редирект'), FormItem::icheckbox('active', 'Статус')->defaultValue(true)], [FormItem::text('alias', 'Алиас')->unique(), FormItem::text('name', 'Название')->required()->unique(), FormItem::image('image', 'Картинка')]])];
$form->items($fields);
return $form;
});
示例15:
if ($instance->active) {
return ' <span><i class="fa fa-chevron-down" data-toggle="tooltip" title="" data-original-title="Active"></i></span>';
}
})->orderable(false)]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->ajax_validation(true);
$form->items([FormItem::columns()->columns([[FormItem::text('lable', 'lable'), FormItem::bsselect('user_id', 'User')->model('App\\User')->display('email')->defaultValue(Sentinel::getUser()->id), FormItem::icheckbox('active')->label('Active')->skin('flat')], [FormItem::text('comment_id', 'Page ID'), FormItem::text('comment_type')]]), FormItem::ckeditor('content', 'Content')]);
return $form;
});
/**
* Sitemaps
*/
Admin::model('App\\Sitemap')->title('Sitemap')->alias('sitemaps')->display(function () {
$display = AdminDisplay::table();
$display->filters([Filter::field('loc')->title(function ($value) {
return 'URL:' . $value;
})]);
$display->columns([Column::checkbox(), Column::string('loc')->label('loc'), Column::string('lastmod')->label('lastmod'), Column::string('changefreq')->label('changefreq'), Column::string('priority')->label('priority'), Column::string('updated_at')->label('updated_at'), Column::custom()->label('in_sitemap')->callback(function ($instance) {
if ($instance->in_sitemap) {
return ' <span><i class="fa fa-chevron-down" data-toggle="tooltip" title="" data-original-title="Active"></i></span>';
}
})->orderable(false)]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->ajax_validation(true);
$form->items([FormItem::columns()->columns([[FormItem::text('loc', 'loc')->required(), FormItem::timestamp('lastmod', 'lastmod')->required(), FormItem::select('changefreq', 'changefreq')->enum(['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'])->required(), FormItem::text('priority', 'priority')->required(), FormItem::icheckbox('in_sitemap')->label('In sitemap')]])]);
return $form;
});