Files
exchange-2.0/app/Classes/Modules/SegmentConstants/ControllerLogic/ListStandardSegmentConstantLogic.php
T
CheeSiong 1fbdc795ff - Segment Company Relationship Service Class
- Update Standard Segment Constant Logic Class
- List Standard Segment Constant Logic Class
- List Standard Segment Logic Class
2020-11-13 14:15:34 +08:00

69 lines
2.0 KiB
PHP

<?php
namespace App\Classes\Modules\SegmentConstants\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\SegmentConstants\Services\ListsSegmentConstants;
use App\Classes\Modules\SegmentConstants\Standards\Rules\CanListStandardSegmentConstants;
use App\Http\Resources\SegmentResource;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ListStandardSegmentConstantLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Standard Segment Constant',
'message' => 'You have successfully retrieved a list of Standard Segment Constant'
];
}
/** @var CanListStandardSegmentConstants */
private $canListStandardSegmentConstants;
/** @var ListsSegmentConstants */
private $listsSegmentConstants;
/**
* ListStandardSegmentConstantLogic constructor.
* @param CanListStandardSegmentConstants $canListStandardSegmentConstants
* @param ListsSegmentConstants $listsSegmentConstants
*/
public function __construct(CanListStandardSegmentConstants $canListStandardSegmentConstants, ListsSegmentConstants $listsSegmentConstants)
{
$this->canListStandardSegmentConstants = $canListStandardSegmentConstants;
$this->listsSegmentConstants = $listsSegmentConstants;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
try {
$this->canListStandardSegmentConstants->passes();
$query = $this->listsSegmentConstants->execute(
[
'segment_id' => 1
]
);
return $this->collectionResponse(SegmentResource::collection($query));
} catch (\Exception $exception){
throw new ErrorException($exception->getMessage(), $exception->getCode());
}
}
}