mirror of
https://gitlab.com/uldvstar/exchange-2.0.git
synced 2026-08-19 12:34:24 +00:00
55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Companies\ControllersLogic;
|
|
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
|
|
use App\Http\Resources\CompanyResource;
|
|
use ErrorException;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class CreateCompanyLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Created Company',
|
|
'message' => 'You have successfully created a new Company'
|
|
];
|
|
}
|
|
|
|
/** @var CreateCompanyProcessor */
|
|
private $createCompanyProcessor;
|
|
|
|
/**
|
|
* CreateCompanyLogic constructor.
|
|
* @param CreateCompanyProcessor $createCompanyProcessor
|
|
*/
|
|
public function __construct(CreateCompanyProcessor $createCompanyProcessor)
|
|
{
|
|
$this->createCompanyProcessor = $createCompanyProcessor;
|
|
}
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws ErrorException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
try {
|
|
|
|
return $this->resourceResponse(new CompanyResource($this->createCompanyProcessor->execute($request)));
|
|
|
|
} catch (\Exception $exception){
|
|
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
|
}
|
|
|
|
}
|
|
|
|
} |