行内编辑

数据表格有一系列方法,来帮助你列表里面直接对数据进行编辑。

注意

每一列设定了行内编辑,需要在form里面有一个相应的field, 比如设定了$table->column('title')->text();,需要同时在表单中设定$form->text('title''),这样行内编辑才能生效

text输入

$table->column('title')->text();

textarea输入

$table->column('title')->textarea();

ip输入

$table->column('ip')->ip();

邮箱输入

$table->column('email')->email();

URL输入

$table->column('url')->url();

金额输入

$table->column('amount')->currency();

decimal小数输入

$table->column('number')->decimal();

integer整数输入

$table->column('number')->integer();

时区输入

$table->column('timezone')->timezone();

select单选

$table->column('option')->select([1 => 'option1', 2 => 'option2', 3 => 'option3']);

select多选

$table->column('options')->multipleSelect([1 => 'option1', 2 => 'option2', 3 => 'option3']);

radio单选

$table->column('options')->radio([1 => 'option1', 2 => 'option2', 3 => 'option3']);

checkbox多选

$table->column('options')->checkbox([1 => 'option1', 2 => 'option2', 3 => 'option3']);

日期选择

$table->column('birth')->date();

日期时间选择

$table->column('published_at')->datetime();

时间选择

$table->column('year')->time();

年份选择

$table->column('year')->year();

月份选择

$table->column('month')->month();

日选择

$table->column('day')->day();

switch开关

注意:在table中对某字段设置了switch,同时需要在form里面对该字段设置同样的switch

快速将列变成开关组件,使用方法如下:

// 设置text、color、和存储值
$states = [
    'on'  => ['value' => 1, 'text' => '打开', 'color' => 'primary'],
    'off' => ['value' => 2, 'text' => '关闭', 'color' => 'default'],
];

$table->column('status')->switch($states);

switch开关组

注意:在table中对某些字段设置了switch,同时需要在form里面对这些字段设置同样的switch

快速将列变成开关组件组,使用方法如下:

$states = [
    'on' => ['text' => 'YES'],
    'off' => ['text' => 'NO'],
];

$table->column('switch_group')->switchGroup([
    'hot'       => '热门',
    'new'       => '最新',
    'recommend' => '推荐',
], $states);

单文件上传

$table->column('file')->upload();

多文件上传

$table->column('files')->uplaodMany();

归属选择

行内编辑支持两个归属选择belongsTobelongsToMany,用来修改归属,分别对应form表单的belongsTobelongsToMany两个组件

belongsTo

参考文档

belongsToMany

参考文档