本文整理汇总了PHP中Column::datetime方法的典型用法代码示例。如果您正苦于以下问题:PHP Column::datetime方法的具体用法?PHP Column::datetime怎么用?PHP Column::datetime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Column
的用法示例。
在下文中一共展示了Column::datetime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFactories
public function testFactories()
{
// char
$this->assertEquals(new CharColumn('foo', 'char', 0), Column::char('foo', 0));
$this->assertEquals(new CharColumn('foo', 'varchar', 0), Column::varchar('foo', 0));
// datetime
$this->assertEquals(new DateTimeColumn('foo'), Column::datetime('foo'));
// decimal
$this->assertEquals(new DecimalColumn('foo', 10, 2), Column::decimal('foo', 10, 2));
// float
$this->assertEquals(new FloatColumn('foo', 10, 2), Column::float('foo', 10, 2));
// int
$this->assertEquals(new IntColumn('foo', 'tinyint'), Column::tinyint('foo'));
$this->assertEquals(new IntColumn('foo', 'smallint'), Column::smallint('foo'));
$this->assertEquals(new IntColumn('foo', 'int'), Column::int('foo'));
$this->assertEquals(new IntColumn('foo', 'mediumint'), Column::mediumint('foo'));
$this->assertEquals(new IntColumn('foo', 'bigint'), Column::bigint('foo'));
$this->assertEquals((new IntColumn('foo', 'tinyint'))->setUnsigned()->setAutoIncrement(), Column::tinyserial('foo'));
$this->assertEquals((new IntColumn('foo', 'smallint'))->setUnsigned()->setAutoIncrement(), Column::smallserial('foo'));
$this->assertEquals((new IntColumn('foo', 'int'))->setUnsigned()->setAutoIncrement(), Column::serial('foo'));
$this->assertEquals((new IntColumn('foo', 'mediumint'))->setUnsigned()->setAutoIncrement(), Column::mediumserial('foo'));
$this->assertEquals((new IntColumn('foo', 'bigint'))->setUnsigned()->setAutoIncrement(), Column::bigserial('foo'));
// text
$this->assertEquals(new TextColumn('foo', 'tinytext'), Column::tinytext('foo'));
$this->assertEquals(new TextColumn('foo', 'text'), Column::text('foo'));
$this->assertEquals(new TextColumn('foo', 'mediumtext'), Column::mediumtext('foo'));
$this->assertEquals(new TextColumn('foo', 'longtext'), Column::longtext('foo'));
// timestamp
$this->assertEquals(new TimestampColumn('foo'), Column::timestamp('foo'));
}
示例2:
<?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;
});
示例3: str_limit
$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) {
$collection->restore();
}
}
})]);
$tabs = [];
$tabs[] = AdminDisplay::tab($mainDisplay)->label('Активные записи')->active(true);
$tabs[] = AdminDisplay::tab($secondaryDisplay)->label('Удаленные записи');
return $tabs;
});
return $display;
});
示例4:
<?php
Admin::model('App\\Directions')->title('Направления')->display(function () {
$display = AdminDisplay::table();
$display->columns([Column::string('name')->label('Название'), Column::datetime('created_at')->label('Дата создания'), Column::datetime('updated_at')->label('Дата изменения')]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::columns()->columns([[FormItem::text('name', 'Название'), FormItem::ckeditor('desc', 'Описание'), FormItem::ckeditor('desc_detail', 'Описание'), FormItem::text('video', 'Видео')], [FormItem::images('images', 'Картинки')]])]);
return $form;
});
示例5:
<?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);
示例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\\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: 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;
});
示例9: view
<?php
Admin::model('App\\Models\\BlogPost')->title('Статьи блога')->display(function () {
$display = AdminDisplay::datatables();
$display->with('user', 'statusName');
$display->filters([]);
$display->columns([Column::string('id')->label('Id'), Column::string('title')->label('Заголовок'), Column::datetime('created_at')->label('Создан')->format('d.m.Y H:i'), Column::string('user.first_name')->label('Автор'), Column::string('statusName.name')->label('Статус')]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::form();
$form->items([FormItem::text('title', 'Заголовок'), FormItem::image('img', 'Изображение'), FormItem::text('slug', 'Slug'), FormItem::select('user_id', 'Автор')->model('App\\User')->display('first_name')->defaultValue(1), FormItem::select('status', 'Статус')->model('App\\Models\\PostStatus')->display('name')->defaultValue(1), FormItem::text('metakey', 'Metakey'), FormItem::text('metadesc', 'Metadesc'), FormItem::ckeditor('text', 'Текст статьи'), FormItem::custom('newtags', 'sssssssssss')->display(function ($instance) {
return view('admin.formitem_tags', ['instance' => $instance]);
})->callback(function ($instance) {
$instance->retag($_POST['newtags']);
})]);
return $form;
});
示例10:
<?php
Admin::model('Lanz\\Commentable\\Comment')->title('Комментарии')->display(function () {
$display = AdminDisplay::datatables();
$display->with();
$display->filters([]);
$display->columns([Column::string('body')->label('Комментарий'), Column::datetime('created_at')]);
return $display;
})->createAndEdit(function ($id) {
if (is_null($id)) {
return null;
}
$form = AdminForm::form();
$form->items([FormItem::select('user_id', 'Автор')->model('App\\User')->display('first_name'), FormItem::ckeditor('body', 'Комментарий')]);
return $form;
});
示例11: use
<?php
/** @var \SleepingOwl\Admin\Model\ModelConfiguration $mdenu */
$model = Admin::model(\App\ScheduleAndCost::class);
$model->title('Блок расписание и стоимость');
$model->display(function () {
$display = AdminDisplay::datatables();
$display->columns([Column::string('title')->label('Заголовок')->orderable(false), Column::datetime('created_at')->label('Создан')->orderable(false), Column::order()->orderable(false)]);
$display->apply(function (\Illuminate\Database\Eloquent\Builder $query) {
$query->withTrashed();
$query->orderBy('order', 'asc');
});
return $display;
})->createAndEdit(function ($id) use($model) {
$model->title($id ? 'Редактировать блок' : 'Создать блок');
$form = AdminForm::form();
$form->items([FormItem::text('title'), FormItem::ckeditor('text')]);
return $form;
});
示例12: 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;
});
示例13:
<?php
/*
* This is a simple example of the main features.
* For full list see documentation.
*/
Admin::model('App\\Models\\Evaluation')->title('Evaluations')->alias('evaluation')->display(function () {
$display = AdminDisplay::datatablesAsync();
$display->order([[7, 'desc']]);
$display->columns([Column::string('member.first_name')->label('User'), Column::string('webpage.url')->label('Url'), Column::string('ip')->label('IP-address'), Column::string('device_type')->label('Type'), Column::string('browser')->label('Browser'), Column::string('platform')->label('Platform'), Column::string('device')->label('Device'), Column::datetime('created_at')->format('d-m-Y h:i:s')->label('Created')]);
$display->columnFilters([null, ColumnFilter::text()->placeholder('Url'), ColumnFilter::text()->placeholder('IP-address'), 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;
})->create(null)->edit(null)->createAndEdit(null)->delete(null);
示例14: 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;
});
示例15:
<?php
/*
* This is a simple example of the main features.
* For full list see documentation.
*/
Admin::model('App\\Models\\Result')->title('Results')->alias('result')->display(function () {
$display = AdminDisplay::datatablesAsync();
$display->order([[7, 'desc']]);
$display->columns([Column::string('evaluation.member.first_name')->label('User'), Column::string('evaluation.webpage.url')->label('Url'), Column::string('module')->label('Module'), Column::string('type')->label('Type'), Column::string('status')->label('Status'), Column::string('value')->label('Value'), Column::string('info')->label('Info'), Column::datetime('created_at')->format('d-m-Y h:i:s')->label('Created')]);
return $display;
})->create(null)->edit(null)->createAndEdit(null)->delete(null);