57 lines
1.1 KiB
PHP
57 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers\Material;
|
|
|
|
use App\Models\Material;
|
|
use Encore\Admin\Controllers\AdminController;
|
|
use Encore\Admin\Form;
|
|
use Encore\Admin\Grid;
|
|
|
|
class IndexController extends AdminController
|
|
{
|
|
|
|
/**
|
|
* Title for current resource.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $title = '物料/素材';
|
|
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
$grid = new Grid(new Material());
|
|
|
|
$grid->column('id', '编号');
|
|
$grid->column('title', '名称');
|
|
$grid->column('地址')->display(function () {
|
|
return $this->cover_url;
|
|
});
|
|
$grid->column('created_at', '创建时间');
|
|
|
|
return $grid;
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form(): Form
|
|
{
|
|
$form = new Form(new Material());
|
|
$form->text('title', '名称');
|
|
$form->image('cover', '图片')
|
|
->move('materials/'.date('Y/m/d'))
|
|
->removable()
|
|
->required();
|
|
|
|
return $form;
|
|
}
|
|
|
|
}
|