本文整理汇总了PHP中Column::string方法的典型用法代码示例。如果您正苦于以下问题:PHP Column::string方法的具体用法?PHP Column::string怎么用?PHP Column::string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Column
的用法示例。
在下文中一共展示了Column::string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
<?php
Admin::model(App\Uom::class)->title('Unit of Measure')->with()->filters(function () {
})->columns(function () {
Column::string('name', 'Name');
Column::string('description', 'Description');
})->form(function () {
FormItem::text('name', 'Name');
FormItem::text('description', 'Description');
});
示例2: switch
<?php
Admin::model(\App\Models\AddonsType::class)->title('Addons Types')->denyEditingAndDeleting(function ($instance) {
return false;
})->columns(function () {
Column::string('id', 'Id');
Column::string('code', 'Code')->inlineEdit(true);
Column::string('name', 'Name')->inlineEdit(true);
})->inlineEdit(function ($field) {
switch ($field) {
case 'code':
return function () {
InlineEditItem::text('code', NULL)->validationRule('required');
};
break;
case 'name':
return function () {
InlineEditItem::text('name', NULL)->validationRule('required');
};
break;
default:
return function () {
};
break;
}
})->form(function () {
FormItem::text('code', 'Code')->validationRule('required');
FormItem::text('name', 'Name')->validationRule('required');
})->viewFilters(function () {
ViewFilter::text('code', 'Code');
ViewFilter::text('name', 'Name');
示例3:
<?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;
});
示例4:
<?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;
});
示例5:
<?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;
});
示例6:
<?php
Admin::model('\\Country')->title('Countries')->with('contacts')->columns(function () {
Column::string('title', 'Title');
Column::count('contacts', 'Contacts')->append(Column::filter('country_id')->model('\\Contact'));
})->form(function () {
FormItem::text('title', 'Title')->required()->unique();
});
示例7: strlen
$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')]);
return $form;
});
示例8:
<?php
Admin::model('App\\Company')->title('Companies')->display(function () {
$display = AdminDisplay::table();
$display->columns([Column::string('title')->label('Title'), Column::string('address')->label('Address')]);
return $display;
})->createAndEdit(function ($id) {
$form = AdminForm::form();
$form->items([FormItem::hidden('contact_id'), FormItem::text('title', 'Title')->required()->unique(), FormItem::text('address', 'Address'), FormItem::text('phone', 'Phone')]);
return $form;
});
示例9: is_null
<?php
Admin::model('App\\Models\\Order')->title('')->display(function () {
$display = AdminDisplay::datatables();
$display->with();
$display->filters([]);
$display->columns([Column::custom()->label('Команда')->callback(function ($instance) {
$product = \App\Models\Product::all()->where('id', $instance->product_id)->first();
return is_null($product) ? 'Неизвестный' : $product->title;
}), Column::string('sum')->label('Сумма'), Column::custom()->label('Статус')->callback(function ($instance) {
if ($instance->status == 0) {
return '<p class="text-warning">Не оплачен</p>';
} elseif ($instance->status == 1) {
return '<p class="text-danger">Ошибка</p>';
} else {
return '<p class="text-success">Оплачен</p>';
}
})]);
return $display;
})->createAndEdit(function () {
return null;
});
示例10:
<?php
/*
* This is a simple example of the main features.
* For full list see documentation.
*/
Admin::model('App\\Models\\Sector')->title('Sectors')->alias('sector')->display(function () {
$display = AdminDisplay::datatablesAsync();
$display->order([[0, 'asc']]);
$display->columns([Column::string('id')->label('Id'), Column::string('name')->label('Name'), 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([null, ColumnFilter::text()->placeholder('Name'), 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;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::text('name', 'Name')->required()]);
return $form;
});
示例11:
<?php
Admin::model(App\Models\Task::class)->title('Задачи')->with('subject')->filters(function () {
})->columns(function () {
Column::string('number_task', 'Number_task');
Column::image('image')->sortable(false);
Column::string('experience', 'Experience');
Column::string('gold', 'Gold');
Column::string('grade', 'Grade');
Column::string('subject.name', 'Subject')->append(Column::filter('subject_id')->value('subject_id'));
Column::string('answer', 'Answer');
Column::string('detail', 'detail');
Column::string('set_of_task', 'Set_of_task');
})->form(function () {
FormItem::text('number_task', 'Number Task');
FormItem::image('image', 'Image');
FormItem::text('experience', 'Experience');
FormItem::text('gold', 'Gold');
FormItem::text('grade', 'Grade');
FormItem::select('subject_id', 'Subject')->list(App\Models\Subject::class);
FormItem::text('answer', 'Answer');
FormItem::text('detail', 'detail');
FormItem::text('set_of_task', 'Set Of Task');
});
示例12: 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) {
示例13: view
<?php
Admin::model('SleepingOwl\\AdminAuth\\Entities\\Administrator')->title('Administrators')->display(function () {
$display = AdminDisplay::datatables();
$display->order([[0, 'desc']]);
$display->columns([Column::string('id')->label('ID'), Column::string('name')->label('Name'), Column::string('username')->label('Username')]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::text('username', 'Username'), FormItem::text('name', 'Name'), FormItem::custom()->display(function ($instance) {
return view('form.password_field', ['instance' => $instance]);
})->callback(function ($instance) {
$instance->password = Input::get('password');
})]);
return $form;
});
示例14:
<?php
Admin::model(App\ColorOrden::class)->title('Orden de colores')->with()->filters(function () {
})->columns(function () {
Column::string('id', 'Id');
Column::string('codigo', 'Codigo');
})->form(function () {
FormItem::text('id', 'Id')->attributes(["readonly" => "readonly"]);
FormItem::text('codigo', 'Codigo');
FormItem::textarea('ordenes', 'Ordenes');
});
示例15: 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;
});