generated from liutk/owl-admin-base
66 lines
2.8 KiB
PHP
66 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
|
use App\Services\Admin\EmployeeService;
|
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
|
use App\Enums\EmployeeStatus;
|
|
|
|
class EmployeeController extends AdminController
|
|
{
|
|
protected string $serviceName = EmployeeService::class;
|
|
|
|
public function list(): Page
|
|
{
|
|
$crud = $this->baseCRUD()
|
|
->tableLayout('fixed')
|
|
->headerToolbar([
|
|
$this->createButton(true),
|
|
...$this->baseHeaderToolBar(),
|
|
])
|
|
->filter($this->baseFilter()->body([
|
|
amis()->GroupControl()->mode('horizontal')->body([
|
|
amisMake()->TextControl()->name('name')->label(__('employee.name'))->columnRatio(3)->clearable(),
|
|
amisMake()->TextControl()->name('phone')->label(__('employee.phone'))->columnRatio(3)->clearable(),
|
|
amisMake()->SelectControl()->name('employee_status')->label(__('employee.employee_status'))->columnRatio(3)->clearable()->options(EmployeeStatus::options()),
|
|
]),
|
|
]))
|
|
->columns([
|
|
amisMake()->TableColumn()->name('id')->label(__('employee.id')),
|
|
amisMake()->TableColumn()->name('name')->label(__('employee.name')),
|
|
amisMake()->TableColumn()->name('phone')->label(__('employee.phone')),
|
|
amisMake()->TableColumn()->name('employee_status_text')->label(__('employee.employee_status')),
|
|
amisMake()->TableColumn()->name('created_at')->label(__('employee.created_at')),
|
|
$this->rowActions([
|
|
$this->rowShowButton(),
|
|
$this->rowEditButton(true),
|
|
$this->rowDeleteButton(),
|
|
]),
|
|
]);
|
|
|
|
return $this->baseList($crud);
|
|
}
|
|
|
|
public function form($edit): Form
|
|
{
|
|
return $this->baseForm()->title('')->body([
|
|
amisMake()->TextControl()->name('name')->label(__('employee.name'))->required(),
|
|
amisMake()->TextControl()->name('phone')->label(__('employee.phone'))->required(),
|
|
|
|
amisMake()->TextControl()->name('username')->label(__('admin.username'))->value('${admin_user.username}')->required(!$edit),
|
|
amisMake()->TextControl()->name('password')->set('type', 'input-password')->label(__('admin.password'))->required(!$edit),
|
|
amisMake()->TextControl()->name('confirm_password')->set('type', 'input-password')->label(__('admin.confirm_password'))->required(!$edit),
|
|
]);
|
|
}
|
|
|
|
public function detail(): Form
|
|
{
|
|
return $this->baseDetail()->title('')->body(amisMake()->Property()->items([
|
|
['label' => __('employee.name'), 'content' => '${name}'],
|
|
['label' => __('employee.phone'), 'content' => '${phone}'],
|
|
]));
|
|
}
|
|
}
|