本文整理汇总了PHP中FormItem::checkbox方法的典型用法代码示例。如果您正苦于以下问题:PHP FormItem::checkbox方法的具体用法?PHP FormItem::checkbox怎么用?PHP FormItem::checkbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormItem
的用法示例。
在下文中一共展示了FormItem::checkbox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: use
<?php
/**
* @var \SleepingOwl\Admin\Model\ModelConfiguration
*/
$model = Admin::model(\App\Page::class);
$model->title('Страницы');
$model->display(function () {
$display = AdminDisplay::datatables();
$display->filters([Filter::field('id')->title(function ($value) {
return 'Выбрана страница с идентификатором: ' . $value;
})]);
$display->columns([Column::string('title')->label('Заголовок'), Column::published('published')->label('Опубликован')->orderable(false), Column::datetime('created_at')->label('Создан')->format('d.m.Y в H:i')]);
$display->columnFilters([null, ColumnFilter::select()->options(['нет' => 'Нет', 'да' => 'Да'])->filter_field('published')]);
return $display;
})->createAndEdit(function ($id) use($model) {
$model->title($id ? 'Редактировать страницу' : 'Создать страницу');
$form = AdminForm::tabbed();
$form->items(['Основное' => [FormItem::text('title', 'Заголовок')->required(), FormItem::checkbox('published', 'Опубликовать'), FormItem::ckeditor('content', 'Содержимое')], 'Мета данные' => [FormItem::textarea('meta_keywords', 'Ключевые слова')->rows(2), FormItem::textarea('meta_description', 'Описание страницы')->rows(4), FormItem::textarea('meta_others', 'Другая мета информация')->rows(7)]]);
return $form;
});
示例2: 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;
});
示例3:
<?php
Admin::model('App\\News4')->title('News')->alias('news4')->display(function () {
$display = AdminDisplay::table();
$display->filters([Filter::scope('last')->title('Latest News'), Filter::field('published')->title(function ($value) {
return $value ? 'Published' : 'Not Published';
}), Filter::custom('limit')->title(function ($value) {
return 'Custom Filter: ' . $value;
})->callback(function ($query, $value) {
$query->limit($value);
})]);
$display->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 ? '✓' : '-';
})]);
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;
});
示例4: view
<?php
Admin::model('\\App\\Category')->title('Управление категориями')->display(function () {
$instance = new App\Category();
$message = Session::get('message');
//('message') ? $message : '';
$categories = $instance->createTree(1);
return view('admin.categories', compact('categories', 'message'));
})->createAndEdit(function ($id) {
$form = AdminForm::form();
$form->items([FormItem::text('title', 'Название категории')->required(), FormItem::select('parent_id', 'Родительская категория')->model('App\\Category')->display('title')->required(), FormItem::checkbox('active', 'Активность')]);
return $form;
});
示例5: getSettings
public function getSettings()
{
$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'];
$items = [\FormItem::select('theme.skin', 'Theme Skin')->options($skins)->defaultValue(\SoaUserSetting::get('theme.skin', config('admintheme.skin'))), \FormItem::checkbox('theme.fixed_layout', 'Fixed Layout')->defaultValue(\SoaUserSetting::get('theme.fixed_layout', config('admintheme.fixed_layout')))->help_text('You can\'t use fixed and boxed layouts together.'), \FormItem::checkbox('theme.boxed_layout', 'Boxed Layout')->defaultValue(\SoaUserSetting::get('theme.boxed_layout', config('admintheme.boxed_layout')))->help_text('You can\'t use fixed and boxed layouts together.'), \FormItem::checkbox('theme.sidebar_mini', 'Minimize Sidebar')->defaultValue(\SoaUserSetting::get('theme.sidebar_mini', config('admintheme.sidebar_mini'))), \FormItem::checkbox('theme.toggle_sidebar', 'Toggle Sidebar')->defaultValue(\SoaUserSetting::get('theme.toggle_sidebar', config('admintheme.toggle_sidebar')))->help_text('Toggle the left sidebar\'s state (open or collapse)'), \FormItem::checkbox('theme.sidebar_on_hover', 'Sidebar on Hover')->defaultValue(\SoaUserSetting::get('theme.sidebar_on_hover', config('admintheme.sidebar_on_hover')))->help_text('Let the sidebar mini expand on hover')];
return $this->render(trans('admin::lang.settings'), view(AdminTemplate::view('pages.admin_settings'), compact('items')));
}
示例6:
<?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;
});
示例7:
<?php
/*
* This is a simple example of the main features.
* For full list see documentation.
*/
Admin::model('App\\Models\\Webpage')->title('Webpages')->alias('webpage')->display(function () {
$display = AdminDisplay::datatablesAsync();
$display->order([[4, 'desc']]);
$display->columns([Column::string('host')->label('Domain'), Column::string('path')->label('Path'), Column::custom()->label('Evaluations')->callback(function ($instance) {
return $instance->evaluations()->count();
}), 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([ColumnFilter::text()->placeholder('Domain'), ColumnFilter::text()->placeholder('Path'), 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;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::checkbox('is_enabled', 'Enabled'), FormItem::text('url', 'URL')->required(), FormItem::ckeditor('description', 'Description')]);
return $form;
})->delete(null);
示例8:
<?php
Admin::model('App\\Models\\Advert')->title('Рекламные блоки')->display(function () {
$display = AdminDisplay::datatables();
$display->with();
$display->filters([Filter::field('active')->title('Вкл')->alias('ddddd')]);
$display->columns([Column::string('id')->label('Id'), Column::string('name')->label('Название'), Column::string('place')->label('Место'), Column::string('active')->label('Включен'), Column::image('img')->label('Img')]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::columns()->columns([[FormItem::text('name', 'Название (только для админа)')], [FormItem::checkbox('active', 'Включен')]]), FormItem::columns()->columns([[FormItem::select('place', 'Место посадки')->enum(['top1', 'aside1', 'aside2', 'recipie_step', 'foot_script'])], []]), FormItem::columns()->columns([[FormItem::text('title', 'Заголовок')], [FormItem::checkbox('show_title', 'Показывать')]]), FormItem::columns()->columns([[FormItem::image('img', 'Изображение')], [FormItem::checkbox('show_img', 'Показывать'), FormItem::text('imglink', 'Ссылка')]]), FormItem::columns()->columns([[FormItem::textarea('text', 'Содержимое')], [FormItem::checkbox('show_text', 'Показывать')]])]);
return $form;
});
示例9: function
InlineEditItem::text('code', NULL)->validationRule('required');
};
break;
case 'name':
return function () {
InlineEditItem::callback('name', '')->callback(function ($instance) {
$content = '';
foreach (Models\Language::get() as $language) {
$value = '';
$descriptions = $instance->descriptions->where('language_id', $language->id)->first();
if (!is_null($descriptions)) {
$value = $descriptions->name;
}
$content .= HtmlBuilder::text('name_' . $language->id, 'Name [' . $language->code . ']', $value, ['data-parsley-required' => true]);
}
return $content;
});
};
break;
default:
return function () {
};
break;
}
})->form(function () {
FormItem::text('code', 'Code')->validationRule('required')->group('status');
FormItem::checkbox('default', 'Default')->group('status');
FormItem::descriptions()->useTabs(true)->type('model')->modelMethod('descriptions')->fields(['name' => ['name' => 'Name', 'value' => 'name', 'type' => 'text', 'validation' => 'required']])->group('descriptions');
FormGroup::create('status', 'Status')->setDisplayType(FormGroup::DISPLAY_TYPE_FULL);
FormGroup::create('descriptions', 'Status Descriptions')->setDisplayType(FormGroup::DISPLAY_TYPE_FULL);
});
示例10: view
<?php
Admin::model('App\\Form')->title('Form Items')->display(function () {
$display = AdminDisplay::table();
$display->columns([Column::string('id')->label('ID'), Column::string('title')->label('String'), Column::datetime('created_at')->label('Created At')->format('d.m.Y H:i:s')]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::columns()->columns([[FormItem::text('title', 'FormItem::text')->defaultValue('default value')->required(), FormItem::textaddon('textaddon', 'FormItem::textaddon')->addon('$')->placement('after'), FormItem::checkbox('checkbox', 'FormItem::checkbox'), FormItem::date('date', 'FormItem::date')->format('d.m.Y'), FormItem::time('time', 'FormItem::time')->format('H:i:s')->seconds(true), FormItem::timestamp('timestamp', 'FormItem::timestamp')->format('d.m.Y g:i A')], [FormItem::select('select', 'FormItem::select')->options([1 => 'First', 2 => 'Second', 3 => 'Third'])->nullable(), FormItem::custom()->display(function ($instance) {
return view('custom_form_item', compact('instance'));
})->callback(function ($instance) {
$instance->custom = \Carbon\Carbon::now();
})], [FormItem::image('image', 'FormItem::image'), FormItem::images('images', 'FormItem::images')]]), FormItem::columns()->columns([[FormItem::textarea('textarea', 'FormItem::textarea')], [FormItem::ckeditor('ckeditor', 'FormItem::ckeditor')]])]);
return $form;
});
示例11:
<?php
/*
* This is a simple example of the main features.
* For full list see documentation.
*/
Admin::model('App\\Models\\License')->title('Licenses')->alias('license')->display(function () {
$display = AdminDisplay::datatablesAsync();
$display->order([[0, 'asc']]);
$display->columns([Column::string('name')->label('Name'), Column::string('duration')->label('Duration'), Column::custom()->label('Enabled')->callback(function ($instance) {
return $instance->is_enabled ? '✓' : '-';
}), Column::custom()->label('Payed version')->callback(function ($instance) {
return $instance->needs_validation ? '✓' : '-';
}), Column::datetime('created_at')->format('d-m-Y h:i:s')->label('Created'), Column::datetime('updated_at')->format('d-m-Y h:i:s')->label('Updated')]);
$display->columnFilters([ColumnFilter::text()->placeholder('Name'), 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')), 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::custom()->display(function ($instance) {
return '<div class="form-group ">
<label for="key">Key</label><br/>
' . $instance->key . '
</div>';
}), FormItem::text('name', 'Name')->required(), FormItem::text('duration', 'Duration')->required(), FormItem::checkbox('is_enabled', 'Enabled'), FormItem::checkbox('needs_validation', 'Payed version'), FormItem::ckeditor('description', 'Description')]);
return $form;
})->create(function () {
$form = AdminForm::form();
$form->items([FormItem::text('name', 'Name')->required(), FormItem::text('duration', 'Duration')->required(), FormItem::checkbox('is_enabled', 'Enabled'), FormItem::checkbox('needs_validation', 'Payed version'), FormItem::ckeditor('description', 'Description')]);
return $form;
});
示例12:
<?php
Admin::model(App\Models\Mega::class)->title('Megas')->with()->filters(function () {
})->columns(function () {
Column::string('string', 'String');
})->form(function () {
FormItem::text('string', 'String')->required();
FormItem::text('integer', 'Integer')->required()->validationRule('integer');
FormItem::image('image', 'Image');
FormItem::checkbox('boolean', 'Boolean');
FormItem::date('date', 'Date')->required();
FormItem::time('time', 'Time')->required();
//->seconds(true);
FormItem::select('choices', 'Choices')->enum(['foo', 'bar']);
FormItem::ckeditor('text', 'Text')->required();
});
示例13:
<?php
Admin::model(\App\Noticia::class)->title('Noticias')->with()->filters(function () {
})->columns(function () {
Column::string('titulo', 'Titulo');
Column::string('habilitado', 'Habilitado');
Column::string('orden', 'Orden');
})->form(function () {
FormItem::text('titulo', 'Titulo');
FormItem::textarea('bajada', 'Bajada');
FormItem::ckeditor('texto', 'Texto');
FormItem::checkbox('habilitado', 'Habilitado');
FormItem::select('orden', 'Orden')->enum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])->nullable();
FormItem::CustomImagenNoticia();
});
示例14: config
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
}
}
}
})]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::text('name', 'Name')->required(), FormItem::text('email', 'Email')->required()->unique(), FormItem::password('password', 'Пароль'), FormItem::checkbox('is_active', 'Активность')]);
return $form;
});
示例15:
<?php
Admin::model(\App\Models\Post::class)->title('Блог')->display(function () {
$display = AdminDisplay::datatables();
$display->columns([Column::string('id')->label('#'), Column::string('title')->label('Заголовок'), Column::custom()->label('Опубликован')->callback(function ($instance) {
return $instance->published ? 'Да' : 'Нет';
}), Column::datetime('created_at')->label('Дата создания')]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::columns()->columns([[FormItem::checkbox('published', 'Опубликован')->defaultValue(1), FormItem::text('title', 'Заголовок')->required(), FormItem::ckeditor('body', 'Текст')->required()]])]);
return $form;
});