mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 04:23:59 +00:00
73 lines
1.9 KiB
PHP
73 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Companies\ControllersLogic;
|
|
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\Companies\Services\DeletesCompany;
|
|
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
|
use App\Classes\Modules\Companies\Standards\Rules\CanDeleteCompany;
|
|
use ErrorException;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class DeleteCompanyLogic extends AbstractControllerLogic
|
|
{
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Deleted Company',
|
|
'message' => 'You have successfully deleted a Company'
|
|
];
|
|
}
|
|
|
|
|
|
/** @var CanDeleteCompany */
|
|
private $canDeleteCompany;
|
|
|
|
/** @var DeletesCompany */
|
|
private $deletesCompany;
|
|
|
|
/** @var FetchesCompany */
|
|
private $fetchesCompany;
|
|
|
|
/**
|
|
* DeleteCompanyLogic constructor.
|
|
* @param CanDeleteCompany $canDeleteCompany
|
|
* @param DeletesCompany $deletesCompany
|
|
* @param FetchesCompany $fetchesCompany
|
|
*/
|
|
public function __construct(CanDeleteCompany $canDeleteCompany, DeletesCompany $deletesCompany, FetchesCompany $fetchesCompany)
|
|
{
|
|
$this->canDeleteCompany = $canDeleteCompany;
|
|
$this->deletesCompany = $deletesCompany;
|
|
$this->fetchesCompany = $fetchesCompany;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws ErrorException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
try {
|
|
|
|
$this->canDeleteCompany->passes();
|
|
|
|
$query = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
|
|
|
$this->deletesCompany->execute($query);
|
|
|
|
return $this->response([]);
|
|
|
|
} catch (\Exception $exception){
|
|
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
|
}
|
|
|
|
}
|
|
|
|
} |