Files
exchange-2.0/app/Classes/Modules/Segments/ControllerLogic/ListStandardSegmentLogic.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

65 lines
1.7 KiB
PHP

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