123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace App\Admin\Forms;
- use Dcat\Admin\Contracts\LazyRenderable;
- use Dcat\Admin\Widgets\Form;
- use App\Admin\Repositories\DistInquiry;
- use App\Admin\Renderable\DistDistributorTable;
- use Dcat\Admin\Models\DistAdminUser;
- use Dcat\Admin\Traits\LazyWidget;
- use App\Models\DistAdminDistributor;
- class InquiryAssignment extends Form
- {
- // 处理请求
- public function handle(array $input)
- {
- $distId = $input['distId'] ?? null;
- $id = $input['id'] ?? null;
- if (empty($id)) {
- return $this->response()->error('No data selected!');
- }
- //检查数据是否可分配状态
- $ids = explode(',', $id);
- if (DistInquiry::assessTheStatus($ids) == false) {
- return $this->response()->error('The data cannot be assigned!');
- }
- //分配数据
- DistInquiry::assignData($ids, $distId);
- return $this->response()->success(admin_trans_label('update_success'))->refresh();
- }
- public function form()
- {
- $this->selectTable('distId', admin_trans_label('select_distributor'))
- ->title('distId')
- ->model(DistAdminDistributor::class, 'id', 'client_code')
- ->from(DistDistributorTable::make());
- // 设置隐藏表单,传递用户id
- $this->hidden('id')->attribute('id', 'inquiryIds');
- }
- }
|