6
0
Fork 0
jiqu-library-server/app/Admin/Controllers/DrawLogController.php

75 lines
2.0 KiB
PHP

<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\DrawLog as DrawLogRepository;
use App\Http\Controllers\Controller;
use App\Models\DrawActivity;
use Dcat\Admin\Form;
use Dcat\Admin\Layout\Content;
class DrawLogController extends Controller
{
protected function title()
{
if (property_exists($this, 'title')) {
return $this->title;
}
return admin_trans_label();
}
protected function description()
{
if (property_exists($this, 'description')) {
return $this->description;
}
}
protected function translation()
{
if (property_exists($this, 'translation')) {
return $this->translation;
}
}
public function edit($drawActivityId, $drawLogId, Content $content)
{
DrawActivity::findOrFail($drawActivityId);
return $content
->translation($this->translation())
->title($this->title())
->description($this->description()['edit'] ?? trans('admin.edit'))
->body($this->form()->edit($drawLogId));
}
public function update($drawActivityId, $drawLogId)
{
DrawActivity::findOrFail($drawActivityId);
return $this->form()->update($drawLogId);
}
protected function form()
{
return Form::make(new DrawLogRepository(), function (Form $form) {
if ($form->isEditing()) {
if ($form->model()->isPending()) {
$form->text('consignee_name', '收件人')
->rules(['bail', 'nullable', 'string', 'max:255']);
$form->text('consignee_phone', '联系方式')
->rules(['bail', 'nullable', 'string', 'max:255']);
$form->text('consignee_address', '收货地址')
->rules(['bail', 'nullable', 'string', 'max:255']);
}
$form->textarea('remark', '备注')
->rules(['bail', 'nullable', 'string', 'max:255']);
}
});
}
}