62 lines
1.3 KiB
PHP
62 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Forms;
|
|
|
|
use App\Models\BargainOrder;
|
|
use Dcat\Admin\Contracts\LazyRenderable;
|
|
use Dcat\Admin\Traits\LazyWidget;
|
|
use Dcat\Admin\Widgets\Form;
|
|
|
|
class BargainOrderRemark extends Form implements LazyRenderable
|
|
{
|
|
use LazyWidget;
|
|
|
|
/**
|
|
* 权限判断,如不需要可以删除此方法
|
|
*
|
|
* @param Model|Authenticatable|HasPermissions|null $user
|
|
*
|
|
* @return bool
|
|
*/
|
|
protected function authorize($user): bool
|
|
{
|
|
return $user->can('dcat.admin.bargain_orders.remark');
|
|
}
|
|
|
|
/**
|
|
* Handle the form request.
|
|
*
|
|
* @param array $input
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle(array $input)
|
|
{
|
|
$orderId = $this->payload['id'] ?? 0;
|
|
$order = BargainOrder::findOrFail($orderId);
|
|
|
|
$remark = $input['remark'] ?? '';
|
|
|
|
$order->update([
|
|
'remark'=>$remark,
|
|
]);
|
|
|
|
return $this->response()
|
|
->success(__('admin.update_succeeded'))
|
|
->refresh();
|
|
}
|
|
|
|
/**
|
|
* Build a form here.
|
|
*/
|
|
public function form()
|
|
{
|
|
$orderId = $this->payload['id'] ?? 0;
|
|
$order = BargainOrder::findOrFail($orderId);
|
|
|
|
$this->text('remark')->value($order->remark);
|
|
|
|
$this->disableResetButton();
|
|
}
|
|
}
|