mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-25 23:44:14 +00:00
WIP - Order steps & remaining APIs
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Remarks\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Remarks\Services\FetchesRemark;
|
||||
use App\Classes\Modules\Remarks\Standards\Rules\CanFetchRemark;
|
||||
use App\Http\Resources\RemarkResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Remark',
|
||||
'message' => 'You have successfully retrieved a Remark'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanFetchRemark */
|
||||
private $canFetchRemark;
|
||||
|
||||
/** @var FetchesRemark */
|
||||
private $fetchesRemark;
|
||||
|
||||
/**
|
||||
* FetchRemarkControllersLogic constructor.
|
||||
* @param CanFetchRemark $canFetchRemark
|
||||
* @param FetchesRemark $fetchesRemark
|
||||
*/
|
||||
public function __construct(CanFetchRemark $canFetchRemark, FetchesRemark $fetchesRemark)
|
||||
{
|
||||
$this->canFetchRemark = $canFetchRemark;
|
||||
$this->fetchesRemark = $fetchesRemark;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$this->canFetchRemark->passes();
|
||||
|
||||
$query = $this->fetchesRemark->execute(['id' => $request->route('id')]);
|
||||
|
||||
return $this->resourceResponse(new RemarkResource($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user