first
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\User\Http\Controllers\Admin\Actions;
|
||||
|
||||
use Encore\Admin\Actions\Response;
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Exception;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateRelation extends RowAction
|
||||
{
|
||||
|
||||
public $name = '变更隶属';
|
||||
|
||||
public function handle(Model $model, Request $request): Response
|
||||
{
|
||||
try {
|
||||
if ($model->updateParent($request->parent_id)) {
|
||||
return $this->response()->success('变更成功')->refresh();
|
||||
} else {
|
||||
return $this->response()->error('变更失败')->refresh();
|
||||
}
|
||||
} catch (Exception $exception) {
|
||||
return $this->response()->error($exception->getMessage())->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
$this->text('parent_id', '目标ID');
|
||||
$this->confirm('确认变更隶属?');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user