mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
8b01421be7
-Update Non Segment Constant Service Class -Create Non Standard Segment Constant Logic Class -Update Non Standard Segment Constant Logic Class -Delete Non Standard Segment Logic Class
83 lines
2.2 KiB
PHP
83 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Segments\ControllersLogic;
|
|
|
|
use App\Http\Resources\SegmentResource;
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
|
|
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
|
|
|
use App\Classes\Modules\Segments\Standards\Rules\CanDeleteSegment;
|
|
use App\Classes\Modules\Segments\Services\DeletesSegment;
|
|
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
|
|
|
use ErrorException;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class DeleteSegmentLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Delete Segment',
|
|
'message' => 'You have successfully deleted the Segment'
|
|
];
|
|
}
|
|
|
|
/** @var CanDeleteSegment */
|
|
private $canDeleteSegment;
|
|
|
|
/** @var DeletesSegment */
|
|
private $deletesSegment;
|
|
|
|
/** @var FetchesSegment */
|
|
private $fetchesSegment;
|
|
|
|
/**
|
|
* UpdateStandardSegmentConstantLogic constructor.
|
|
* @param CanUpdateSegment $canDeleteSegment
|
|
* @param UpdatesSegment $deletesSegment
|
|
* @param FetchesSegment $fetchesSegment
|
|
*/
|
|
public function __construct(
|
|
CanDeleteSegment $canDeleteSegment,
|
|
DeletesSegment $deletesSegment,
|
|
FetchesSegment $fetchesSegment
|
|
)
|
|
{
|
|
$this->canDeleteSegment = $canDeleteSegment;
|
|
$this->deletesSegment = $deletesSegment;
|
|
$this->fetchesSegment = $fetchesSegment;
|
|
}
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws ErrorException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
try {
|
|
DB::beginTransaction();
|
|
|
|
$segment_query = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
|
$this->canDeleteSegment->passes();
|
|
$this->deletesSegment->execute($segment_query);
|
|
|
|
DB::commit();
|
|
|
|
return $this->resourceResponse(new SegmentResource($segment_query));
|
|
|
|
} catch (\Exception $exception){
|
|
dd($exception);
|
|
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
|
}
|
|
}
|
|
|
|
} |