mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
62 lines
1.6 KiB
PHP
62 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Companies\ControllersLogic;
|
|
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
|
use App\Classes\Modules\Companies\Standards\Rules\CanFetchCompany;
|
|
use App\Http\Resources\CompanyResource;
|
|
use ErrorException;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class FetchCompanyLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Retrieved Company',
|
|
'message' => 'You have successfully retrieved a Company'
|
|
];
|
|
}
|
|
|
|
/** @var CanFetchCompany */
|
|
private $canFetchCompany;
|
|
|
|
/** @var FetchesCompany */
|
|
private $fetchesCompany;
|
|
|
|
/**
|
|
* FetchCompanyControllersLogic constructor.
|
|
* @param CanFetchCompany $canFetchCompany
|
|
* @param FetchesCompany $fetchesCompany
|
|
*/
|
|
public function __construct(CanFetchCompany $canFetchCompany, FetchesCompany $fetchesCompany)
|
|
{
|
|
$this->canFetchCompany = $canFetchCompany;
|
|
$this->fetchesCompany = $fetchesCompany;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
$this->canFetchCompany->passes();
|
|
|
|
$query = $this->fetchesCompany->execute(['id' => $request->route('id'), 'with_bookings' => true, 'with_wallets' => true]);
|
|
|
|
return $this->resourceResponse(new CompanyResource($query));
|
|
|
|
}
|
|
|
|
}
|