| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Http\Controllers; |
| 4 |
|
| 5 |
use FluentForm\Framework\Validator\ValidationException; |
| 6 |
use FluentForm\App\Services\Manager\ManagerService; |
| 7 |
|
| 8 |
class ManagersController extends Controller |
| 9 |
{ |
| 10 |
public function index(ManagerService $managerService) |
| 11 |
{ |
| 12 |
$result = $managerService->getManagers($this->request->all()); |
| 13 |
return $this->sendSuccess($result); |
| 14 |
} |
| 15 |
|
| 16 |
public function addManager(ManagerService $managerService) |
| 17 |
{ |
| 18 |
try { |
| 19 |
$result = $managerService->addManager($this->request->all()); |
| 20 |
return $this->sendSuccess($result); |
| 21 |
} catch (ValidationException $exception) { |
| 22 |
return $this->sendError($exception->errors(), 422); |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
public function removeManager(ManagerService $managerService) |
| 27 |
{ |
| 28 |
try { |
| 29 |
$result = $managerService->removeManager($this->request->all()); |
| 30 |
return $this->sendSuccess($result); |
| 31 |
} catch (ValidationException $exception) { |
| 32 |
return $this->sendError($exception->errors(), 422); |
| 33 |
} |
| 34 |
} |
| 35 |
} |
| 36 |
|