2023-07-07 00:07:19 +06:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Private;
|
|
|
|
|
2023-07-12 23:44:53 +06:00
|
|
|
use App\Contracts\ServiceResultError as ServiceResultErrorContract;
|
2023-07-07 00:07:19 +06:00
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
|
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
|
|
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
2023-07-12 23:44:53 +06:00
|
|
|
use Illuminate\Http\Response;
|
2023-07-07 00:07:19 +06:00
|
|
|
use Illuminate\Routing\Controller as BaseController;
|
|
|
|
|
|
|
|
class Controller extends BaseController
|
|
|
|
{
|
|
|
|
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
2023-07-12 23:44:53 +06:00
|
|
|
|
|
|
|
final protected function errors(ServiceResultErrorContract $result): never
|
|
|
|
{
|
|
|
|
if ($result->getCode() === Response::HTTP_UNPROCESSABLE_ENTITY) {
|
|
|
|
redirect()->back()->withInput()->withErrors($result->getErrors());
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
abort($result->getCode(), $result->getMessage());
|
|
|
|
}
|
2023-07-07 00:07:19 +06:00
|
|
|
}
|