mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0bbf0f9138 | |||
| 2c39c66a2d | |||
| a56b5c64ba | |||
| 86401cdad6 | |||
| 558868d859 | |||
| 149029bc24 | |||
| ab84ca4719 | |||
| 6a4e2926b9 | |||
| e7afc0bc10 | |||
| 999c29411f | |||
| c5183ac0a7 | |||
| 896a101fad |
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\ResourceConflictException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounts\Processors\CreateUserProcessor;
|
||||
use App\Classes\Modules\Accounts\Processors\GenerateEmailVerificationAttemptProcessor;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\UserResource;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AddNewMemberLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
public function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated Email',
|
||||
'message' => 'Successfully updated email'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @var AssignEmployeeProcessor
|
||||
*/
|
||||
private $assignEmployeeProcessor;
|
||||
|
||||
/**
|
||||
* @var GenerateEmailVerificationAttemptProcessor
|
||||
*/
|
||||
private $generateEmailVerificationAttemptProcessor;
|
||||
|
||||
/**
|
||||
* AddNewMemberLogic constructor.
|
||||
* @param AssignEmployeeProcessor $assignEmployeeProcessor
|
||||
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
||||
*/
|
||||
public function __construct(AssignEmployeeProcessor $assignEmployeeProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor)
|
||||
{
|
||||
$this->assignEmployeeProcessor = $assignEmployeeProcessor;
|
||||
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ResourceConflictException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$user = Auth::user()->replicate();
|
||||
$user->email = $request->input('email');
|
||||
$user->status = ApprovalStatus::PENDING_VERIFICATION;
|
||||
$user->save();
|
||||
} catch (QueryException $exception){
|
||||
throw new ResourceConflictException('Unable to change your email address as it already exists');
|
||||
}
|
||||
|
||||
if($company = Auth::user()->companyModule()->first()){
|
||||
$Object = new EmploymentObject($company, $user);
|
||||
$this->assignEmployeeProcessor->execute($Object);
|
||||
}
|
||||
|
||||
$this->generateEmailVerificationAttemptProcessor->execute($user);
|
||||
|
||||
return $this->resourceResponse(new UserResource($user));
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Processors\AssignAnnouncementToSegmentProcessor;
|
||||
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignAnnouncementToSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Assign Announcement To Segment',
|
||||
'message' => 'You have successfully assigned Announcement to segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesAnnouncement */
|
||||
private $fetchesAnnouncement;
|
||||
|
||||
/** @var AssignAnnouncementToSegmentProcessor */
|
||||
private $assignAnnouncementToSegmentProcessor;
|
||||
|
||||
/**
|
||||
* AssignAnnouncementToSegmentLogic constructor.
|
||||
* @param FetchesAnnouncement $fetchesAnnouncement
|
||||
* @param AssignAnnouncementToSegmentProcessor $assignAnnouncementToSegmentProcessor
|
||||
*/
|
||||
public function __construct(FetchesAnnouncement $fetchesAnnouncement, AssignAnnouncementToSegmentProcessor $assignAnnouncementToSegmentProcessor)
|
||||
{
|
||||
$this->fetchesAnnouncement = $fetchesAnnouncement;
|
||||
$this->assignAnnouncementToSegmentProcessor = $assignAnnouncementToSegmentProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$announcement = $this->fetchesAnnouncement->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->assignAnnouncementToSegmentProcessor->execute($announcement, $request->input('segment_id'));
|
||||
|
||||
return $this->resourceResponse(new AnnouncementResource($announcement));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanCreateAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\CreatesAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Processors\AssignAnnouncementToSegmentProcessor;
|
||||
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateAnnouncementLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Annoucement',
|
||||
'message' => 'You have successfully created a new Annoucements'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateAnnouncement */
|
||||
private $canCreateAnnouncement;
|
||||
|
||||
/** @var CreatesAnnoucement */
|
||||
private $createsAnnoucement;
|
||||
|
||||
/** @var AssignAnnouncementToSegmentProcessor */
|
||||
private $assignAnnouncementToSegmentProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* CreateAnnouncementLogic constructor.
|
||||
* @param CanCreateAnnoucement $canCreateAnnoucement
|
||||
* @param CreatesAnnoucement $createsAnnoucement
|
||||
* @param AssignAnnouncementToSegmentProcessor $assignAnnouncementToSegmentProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
CanCreateAnnouncement $canCreateAnnouncement,
|
||||
CreatesAnnouncement $createsAnnoucement,
|
||||
AssignAnnouncementToSegmentProcessor $assignAnnouncementToSegmentProcessor
|
||||
) {
|
||||
$this->canCreateAnnouncement = $canCreateAnnouncement;
|
||||
$this->createsAnnoucement = $createsAnnoucement;
|
||||
$this->assignAnnouncementToSegmentProcessor = $assignAnnouncementToSegmentProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$annoucement_object = new AnnouncementObject(
|
||||
$request->input('title'),
|
||||
$request->input('description'),
|
||||
$request->input('starting_on'),
|
||||
$request->input('ending_on')
|
||||
);
|
||||
|
||||
$this->canCreateAnnouncement->passes($annoucement_object);
|
||||
|
||||
$announcement = $this->createsAnnoucement->execute($annoucement_object);
|
||||
|
||||
$this->assignAnnouncementToSegmentProcessor->execute($announcement);
|
||||
|
||||
return $this->resourceResponse(new AnnouncementResource($announcement));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanDeleteAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\DeletesAnnouncement;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteAnnouncementLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Delete Announcement',
|
||||
'message' => 'You have successfully deleted the Announcement'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanDeleteAnnouncement */
|
||||
private $canDeleteAnnouncement;
|
||||
|
||||
/** @var FetchesAnnouncement */
|
||||
private $fetchesAnnouncement;
|
||||
|
||||
/** @var DeletesAnnouncement */
|
||||
private $deletesAnnouncement;
|
||||
|
||||
/**
|
||||
* DeleteAnnouncementLogic constructor.
|
||||
* @param CanDeleteAnnouncement $canDeleteAnnouncement
|
||||
* @param FetchesAnnouncement $fetchesAnnouncement
|
||||
* @param DeletesAnnouncement $deletesAnnouncement
|
||||
*/
|
||||
public function __construct(
|
||||
CanDeleteAnnouncement $canDeleteAnnoucement,
|
||||
FetchesAnnouncement $fetchesAnnoucement,
|
||||
DeletesAnnouncement $deletesAnnoucement
|
||||
) {
|
||||
$this->canDeleteAnnoucement = $canDeleteAnnoucement;
|
||||
$this->fetchesAnnoucement = $fetchesAnnoucement;
|
||||
$this->deletesAnnoucement = $deletesAnnoucement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$this->canDeleteAnnoucement->passes();
|
||||
|
||||
$annoucement = $this->fetchesAnnoucement->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->deletesAnnoucement->execute($annoucement);
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Announcements\Services\ListsAnnouncements;
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanListAnnouncements;
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListAnnouncementsLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieve Announcements',
|
||||
'message' => 'You have successfully retrieved a list of Announcements'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanListAnnouncements */
|
||||
private $canListAnnouncements;
|
||||
|
||||
/** @var ListsAnnouncements */
|
||||
private $listsAnnouncements;
|
||||
|
||||
/**
|
||||
* ListAnnouncementsLogic constructor.
|
||||
* @param CanListAnnouncements $canListAnnouncements
|
||||
* @param ListsAnnouncements $listsAnnouncements
|
||||
*/
|
||||
public function __construct(CanListAnnouncements $canListAnnouncements, ListsAnnouncements $listsAnnouncements)
|
||||
{
|
||||
$this->canListAnnouncements = $canListAnnouncements;
|
||||
$this->listsAnnouncements = $listsAnnouncements;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$this->canListAnnouncements->passes();
|
||||
|
||||
$annoucements = $this->listsAnnouncements->execute($this->listsAnnouncements->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(AnnouncementResource::collection($annoucements));
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\Modules\Announcements\Services\RemovesAnnouncementFromSegment;
|
||||
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RemoveSegmentFromAnnouncementLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Detach Announcement From Segment',
|
||||
'message' => 'You have successfully detached Announcement from segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesAnnouncement */
|
||||
private $fetchesAnnnouncement;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var RemovesAnnouncementFromSegment */
|
||||
private $removesAnnouncementFromSegment;
|
||||
|
||||
/**
|
||||
* RemoveSegmentFromAnnouncementLogic constructor.
|
||||
* @param FetchesAnnouncement $fetchesAnnnouncement
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
* @param RemovesAnnouncementFromSegment $removesAnnouncementFromSegment
|
||||
*/
|
||||
public function __construct(FetchesAnnouncement $fetchesAnnnouncement, FetchesSegment $fetchesSegment, RemovesAnnouncementFromSegment $removesAnnouncementFromSegment)
|
||||
{
|
||||
$this->fetchesAnnnouncement = $fetchesAnnnouncement;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
$this->removesAnnouncementFromSegment = $removesAnnouncementFromSegment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$announcement = $this->fetchesAnnnouncement->execute(['id' => $request->route('id')]);
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $request->route('segment_id')]);
|
||||
|
||||
$this->removesAnnouncementFromSegment->execute($announcement, $segment);
|
||||
|
||||
return $this->resourceResponse(new AnnouncementResource($announcement));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanUpdateAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\UpdatesAnnouncement;
|
||||
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class UpdateAnnouncementLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Update Announcement',
|
||||
'message' => 'You have successfully updated the Announcement'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateAnnouncement */
|
||||
private $canUpdateAnnouncement;
|
||||
|
||||
/** @var FetchesAnnouncement */
|
||||
private $fetchesAnnouncement;
|
||||
|
||||
/** @var UpdatesAnnouncement */
|
||||
private $updatesAnnouncement;
|
||||
|
||||
/**
|
||||
* UpdateAnnouncementLogic constructor.
|
||||
* @param CanUpdateAnnouncement $canUpdateAnnouncement
|
||||
* @param FetchesAnnouncement $fetchesAnnouncement
|
||||
* @param UpdatesAnnouncement $updatesAnnouncement
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateAnnouncement $canUpdateAnnouncement,
|
||||
FetchesAnnouncement $fetchesAnnouncement,
|
||||
UpdatesAnnouncement $updatesAnnouncement
|
||||
) {
|
||||
$this->canUpdateAnnouncement = $canUpdateAnnouncement;
|
||||
$this->fetchesAnnouncement = $fetchesAnnouncement;
|
||||
$this->updatesAnnouncement = $updatesAnnouncement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$annoucement_object = new AnnouncementObject(
|
||||
$request->input('title'),
|
||||
$request->input('description'),
|
||||
$request->input('starting_on'),
|
||||
$request->input('ending_on')
|
||||
);
|
||||
|
||||
$this->canUpdateAnnouncement->passes($annoucement_object);
|
||||
|
||||
$annoucement = $this->fetchesAnnouncement->execute(['id' => $request->route('id')]);
|
||||
|
||||
$announcement_query = $this->updatesAnnouncement->execute($annoucement, $annoucement_object);
|
||||
|
||||
//$announcement_query->segments()->sync($request->input('segment_id'));
|
||||
|
||||
return $this->resourceResponse(new AnnouncementResource($announcement_query));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class AnnouncementObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $title;
|
||||
|
||||
/** @var string */
|
||||
private $description;
|
||||
|
||||
/** @var string */
|
||||
private $starting_on;
|
||||
|
||||
/** @var string */
|
||||
private $ending_on;
|
||||
|
||||
|
||||
/**
|
||||
* AnnouncementObject constructor.
|
||||
* @param string $title
|
||||
* @param string $description
|
||||
* @param string $start_date
|
||||
* @param string $end_date
|
||||
*/
|
||||
|
||||
public function __construct(string $title, string $description, string $starting_on, string $ending_on)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->description = $description;
|
||||
$this->starting_on = $starting_on;
|
||||
$this->ending_on = $ending_on;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStartingOn(): string
|
||||
{
|
||||
return $this->starting_on;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEndingOn(): string
|
||||
{
|
||||
return $this->ending_on;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Processors;
|
||||
|
||||
use App\Classes\Modules\Announcements\Services\AssignsAnnouncementToSegment;
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanAssignSegment;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Models\Announcement;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AssignAnnouncementToSegmentProcessor
|
||||
{
|
||||
|
||||
/** @var CanAssignSegment */
|
||||
private $canAssignSegment;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var AssignAnnouncementToSegment */
|
||||
private $assignsAnnouncementToSegment;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* AssignAnnouncementToSegmentProcessor constructor.
|
||||
* @param CanAssignSegment $canAssignSegment
|
||||
* @param AssignAnnouncementToSegment $assignsAnnouncementToSegment
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
*/
|
||||
public function __construct(CanAssignSegment $canAssignSegment, FetchesSegment $fetchesSegment, AssignsAnnouncementToSegment $assignsAnnouncementToSegment)
|
||||
{
|
||||
$this->canAssignSegment = $canAssignSegment;
|
||||
$this->assignsAnnouncementToSegment = $assignsAnnouncementToSegment;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Announcement $announcement
|
||||
* @param int|null $segmentId
|
||||
* @return Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Announcement $announcement, ?int $segmentId = SegmentConstants::STANDARD_SEGMENT): Model
|
||||
{
|
||||
$this->canAssignSegment->passes();
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $segmentId]);
|
||||
|
||||
return $this->assignsAnnouncementToSegment->execute($announcement, $segment);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Announcement;
|
||||
use App\Models\Segment;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class AssignsAnnouncementToSegment extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param Announcement $announcement
|
||||
* @param Segment $segment
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(Announcement $announcement, Segment $segment)
|
||||
{
|
||||
try {
|
||||
|
||||
$announcement->segments()->attach($segment);
|
||||
|
||||
return $announcement;
|
||||
|
||||
} catch (QueryException $exception){
|
||||
throw new MalformedRequestException($exception);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class CreatesAnnouncement extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(AnnouncementObject $object)
|
||||
{
|
||||
$model = new Announcement();
|
||||
$model->title = $object->getTitle();
|
||||
$model->description = $object->getDescription();
|
||||
$model->starting_on = $object->getStartingOn();
|
||||
$model->ending_on = $object->getEndingOn();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractDeleteRecord;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class DeletesAnnouncement extends AbstractDeleteRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Announcement $model
|
||||
* @return mixed
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Announcement $model) {
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class FetchesAnnouncement extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var Announcement */
|
||||
private $repository;
|
||||
|
||||
|
||||
/**
|
||||
* FetchesAnnouncement constructor.
|
||||
* @param Announcement $repository
|
||||
*/
|
||||
public function __construct(Announcement $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class ListsAnnouncements extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var Announcement */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsAnnouncement constructor.
|
||||
* @param Announcement $repository
|
||||
*/
|
||||
public function __construct(Announcement $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Announcement;
|
||||
use App\Models\Segment;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class RemovesAnnouncementFromSegment extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param Announcement $announcement
|
||||
* @param Segment $segment
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(Announcement $announcement, Segment $segment)
|
||||
{
|
||||
try {
|
||||
|
||||
$announcement->segments()->detach($segment);
|
||||
|
||||
return $announcement;
|
||||
|
||||
} catch (QueryException $exception){
|
||||
throw new MalformedRequestException($exception);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class UpdatesAnnouncement extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Announcement $model
|
||||
* @param AnnouncementObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Announcement $model, AnnouncementObject $object)
|
||||
{
|
||||
$model->title = $object->getTitle();
|
||||
$model->description = $object->getDescription();
|
||||
$model->starting_on = $object->getStartingOn();
|
||||
$model->ending_on = $object->getEndingOn();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantObject;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
|
||||
class CanAssignSegment extends AbstractRule
|
||||
{
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConstantObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConstantObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Announcements\Standards\Validators\AnnouncementValidation;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\AnnouncementObject;
|
||||
|
||||
class CanCreateAnnouncement extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var AnnouncementValidation */
|
||||
private $AnnouncementValidation;
|
||||
|
||||
/**
|
||||
* CanCreateAnnouncement constructor.
|
||||
* @param AnnouncementValidation $AnnouncementValidation
|
||||
*/
|
||||
public function __construct(AnnouncementValidation $AnnouncementValidation)
|
||||
{
|
||||
$this->AnnouncementValidation = $AnnouncementValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->AnnouncementValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Announcement\DataTransferObjects\AnnouncementObject;
|
||||
|
||||
class CanDeleteAnnouncement extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
|
||||
class CanListAnnouncements extends AbstractRule
|
||||
{
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Classes\Modules\Announcements\Standards\Validators\AnnouncementValidation;
|
||||
|
||||
class CanUpdateAnnouncement extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var AnnouncementValidation */
|
||||
private $AnnouncementValidation;
|
||||
|
||||
|
||||
/**
|
||||
* CanUpdateAnnouncement constructor.
|
||||
* @param AnnouncementValidation $AnnouncementValidation
|
||||
*/
|
||||
public function __construct(AnnouncementValidation $AnnouncementValidation)
|
||||
{
|
||||
$this->AnnouncementValidation = $AnnouncementValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->AnnouncementValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
|
||||
class AnnouncementValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'title' => $object->getTitle(),
|
||||
'description' => $object->getDescription(),
|
||||
'starting_on' => $object->getStartingOn(),
|
||||
'ending_on' => $object->getEndingOn()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'required',
|
||||
'description' => 'required',
|
||||
'starting_on' => 'required',
|
||||
'ending_on' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Services\CreatesRemark;
|
||||
use App\Models\Container;
|
||||
use App\Models\Remark;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Container',
|
||||
'message' => 'You have successfully created a new Container'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatesRemark */
|
||||
private $createsRemark;
|
||||
|
||||
/**
|
||||
* CreateContainerRemarkLogic constructor.
|
||||
* @param CreatesRemark $createsRemark
|
||||
*/
|
||||
public function __construct(CreatesRemark $createsRemark)
|
||||
{
|
||||
$this->createsRemark = $createsRemark;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
// get the container
|
||||
$container = Container::findOrFail($request->input('container_id'));
|
||||
|
||||
$object = new RemarkObject($request->input('content'), 1);
|
||||
|
||||
$remark = $this->createsRemark->execute($container, $object);
|
||||
|
||||
return $remark;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Packages;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Services\CreatesRemark;
|
||||
use App\Http\Resources\ContactResource;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use App\Models\Package;
|
||||
use App\Models\Remark;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreatePackageRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Package',
|
||||
'message' => 'You have successfully created a new Package'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatesRemark */
|
||||
private $createsRemark;
|
||||
|
||||
/**
|
||||
* CreateContainerRemarkLogic constructor.
|
||||
* @param CreatesRemark $createsRemark
|
||||
*/
|
||||
public function __construct(CreatesRemark $createsRemark, FetchesOrder $fetchesOrder)
|
||||
{
|
||||
$this->createsRemark = $createsRemark;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
}
|
||||
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
|
||||
$object = new RemarkObject($request->input('content'), auth()->user()->id);
|
||||
|
||||
$remark = $this->createsRemark->execute($order ,$object);
|
||||
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
}
|
||||
|
||||
}
|
||||
+4
-4
@@ -9,7 +9,7 @@ use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\PackingLists\ControllersLogic\Packages\CreatePackageRemarkLogic;
|
||||
use App\Classes\Modules\PackingLists\ControllersLogic\Packages\CreatePackageLogic;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
@@ -60,7 +60,7 @@ class FetchWarehouseReceiveListFromVTPortalProcessor
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
/** @var CreatePackageRemarkLogic */
|
||||
/** @var CreatePackageLogic */
|
||||
private $createPackage;
|
||||
|
||||
/** @var CreatePackageProcessor */
|
||||
@@ -82,12 +82,12 @@ class FetchWarehouseReceiveListFromVTPortalProcessor
|
||||
* @param CreateOrderProcessor $createOrderProcessor
|
||||
* @param FetchesPackingList $fetchesPakcingList
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
* @param CreatePackageRemarkLogic $createPackage
|
||||
* @param CreatePackageLogic $createPackage
|
||||
* @param CreatePackageProcessor $createPackageProcessor
|
||||
* @param CreatesTransport $createsTransport
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
*/
|
||||
public function __construct(FetchesDataFromVTPortal $fetchesDataFRomVTPortal, CleansOldAddress $cleansOldAddress, CreateAddressFromOldAddressProcessor $createAddressFromOldAddressProcessor, FetchesCompanyModule $fetchesCompanyModule, FetchesOrder $fetchesOrder, CreateOrderProcessor $createOrderProcessor, FetchesPackingList $fetchesPakcingList, CreatePackingListProcessor $createPackingListProcessor, CreatePackageRemarkLogic $createPackage, CreatePackageProcessor $createPackageProcessor, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule)
|
||||
public function __construct(FetchesDataFromVTPortal $fetchesDataFRomVTPortal, CleansOldAddress $cleansOldAddress, CreateAddressFromOldAddressProcessor $createAddressFromOldAddressProcessor, FetchesCompanyModule $fetchesCompanyModule, FetchesOrder $fetchesOrder, CreateOrderProcessor $createOrderProcessor, FetchesPackingList $fetchesPakcingList, CreatePackingListProcessor $createPackingListProcessor, CreatePackageLogic $createPackage, CreatePackageProcessor $createPackageProcessor, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule)
|
||||
{
|
||||
$this->fetchesDataFRomVTPortal = $fetchesDataFRomVTPortal;
|
||||
$this->cleansOldAddress = $cleansOldAddress;
|
||||
|
||||
@@ -4,7 +4,9 @@ namespace App\Classes\Modules\Remarks\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\General\Interfaces\Remarkable;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Models\Container;
|
||||
use App\Models\Remark;
|
||||
use App\Models\User;
|
||||
|
||||
@@ -12,18 +14,18 @@ class CreatesRemark extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Company $company
|
||||
* @param Remarkable $remarkable
|
||||
* @param RemarkObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(User $user, RemarkObject $object) {
|
||||
public function execute(Remarkable $remarkable, RemarkObject $object) {
|
||||
$model = new Remark();
|
||||
|
||||
$model->commenter_id = $object->getCommenterId();
|
||||
$model->content = $object->getContent();
|
||||
|
||||
return $this->handler($user->remarks(), $model);
|
||||
return $this->handler($remarkable->remarks(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Segments\Standards\Rules\CanCreateSegment;
|
||||
use App\Classes\Modules\Segments\Services\CreatesSegment;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
use App\Http\Resources\SegmentResource;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Segment',
|
||||
'message' => 'You have successfully created a new Segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateSegment */
|
||||
private $canCreateSegment;
|
||||
|
||||
/** @var CreatesSegment */
|
||||
private $createsSegment;
|
||||
|
||||
|
||||
/**
|
||||
* CreateSegmentLogic constructor.
|
||||
* @param CanCreateSegment $canCreateSegment
|
||||
* @param CreatesSegment $createsSegment
|
||||
*/
|
||||
public function __construct(CanCreateSegment $canCreateSegment, CreatesSegment $createsSegment)
|
||||
{
|
||||
$this->canCreateSegment = $canCreateSegment;
|
||||
$this->createsSegment = $createsSegment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$segment_object = new SegmentObject($request->input('name'));
|
||||
|
||||
$this->canCreateSegment->passes($segment_object);
|
||||
$segment = $this->createsSegment->execute($segment_object);
|
||||
|
||||
return $this->resourceResponse(new SegmentResource($segment));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?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 Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* DeleteSegmentLogic constructor.
|
||||
* @param CanDeleteSegment $canDeleteSegment
|
||||
* @param DeletesSegment $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 \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$segment_query = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
||||
$this->canDeleteSegment->passes();
|
||||
$this->deletesSegment->execute($segment_query);
|
||||
|
||||
return $this->resourceResponse(new SegmentResource($segment_query));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
||||
use App\Http\Resources\ConstantResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchConstantLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Fetch Segment Constant',
|
||||
'message' => 'You have successfully retrieved the Segment Constant'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesConstant */
|
||||
private $fetchesConstant;
|
||||
|
||||
/**
|
||||
* FetchConstantLogic constructor.
|
||||
* @param FetchesConstant $fetchesConstant
|
||||
*/
|
||||
public function __construct(FetchesConstant $fetchesConstant)
|
||||
{
|
||||
$this->fetchesConstant = $fetchesConstant;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$constant = $this->fetchesConstant->execute(['segment_id' => $request->route('id'), 'reference' => $request->route('reference')]);
|
||||
|
||||
return $this->resourceResponse(new ConstantResource($constant));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\Standards\Rules\CanFetchSegment;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Http\Resources\SegmentResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Segment',
|
||||
'message' => 'You have successfully retrieved a segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanFetchSegment */
|
||||
private $canFetchSegment;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/**
|
||||
* FetchSegmentLogic constructor.
|
||||
* @param CanFetchSegment $canFetchSegment
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
*/
|
||||
public function __construct(CanFetchSegment $canFetchSegment, FetchesSegment $fetchesSegment)
|
||||
{
|
||||
$this->canFetchSegment = $canFetchSegment;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canFetchSegment->passes();
|
||||
|
||||
$query = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
||||
|
||||
return $this->resourceResponse(new SegmentResource($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\Services\ListsSegments;
|
||||
use App\Http\Resources\SegmentResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Segment',
|
||||
'message' => 'You have successfully retrieved a list of Segment'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var ListsSegments */
|
||||
private $listsSegments;
|
||||
|
||||
/**
|
||||
* ListSegmentLogic constructor.
|
||||
* @param ListsSegments $listsSegments
|
||||
*/
|
||||
public function __construct(ListsSegments $listsSegments)
|
||||
{
|
||||
$this->listsSegments = $listsSegments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$query = $this->listsSegments->execute($this->listsSegments->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(SegmentResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Classes\Modules\Segments\Services\CreatesConstant;
|
||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\Modules\Segments\Standards\Rules\CanCreateConstant;
|
||||
use App\Classes\Modules\Segments\Standards\Rules\CanUpdateConstant;
|
||||
use App\Classes\Modules\Segments\Services\UpdatesConstant;
|
||||
use App\Http\Resources\ConstantResource;
|
||||
use App\Models\SegmentConstant;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateConstantLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Segment Constant',
|
||||
'message' => 'You have successfully updated the Segment Constant'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateConstant */
|
||||
private $canUpdateConstant;
|
||||
|
||||
/** @var UpdatesConstant */
|
||||
private $updatesConstant;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var FetchesConstant */
|
||||
private $fetchesConstant;
|
||||
|
||||
/** @var CanCreateConstant */
|
||||
private $canCreateConstant;
|
||||
|
||||
/** @var CreatesConstant */
|
||||
private $createsConstant;
|
||||
|
||||
|
||||
/**
|
||||
* UpdateConstantLogic constructor.
|
||||
* @param CanUpdateConstant $canUpdateConstant
|
||||
* @param UpdatesConstant $updatesConstant
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
* @param FetchesConstant $fetchesConstant
|
||||
* @param CanCreateConstant $canCreateConstant
|
||||
* @param CreatesConstant $createsConstant
|
||||
*/
|
||||
public function __construct(CanUpdateConstant $canUpdateConstant, UpdatesConstant $updatesConstant, FetchesSegment $fetchesSegment, FetchesConstant $fetchesConstant, CanCreateConstant $canCreateConstant, CreatesConstant $createsConstant)
|
||||
{
|
||||
$this->canUpdateConstant = $canUpdateConstant;
|
||||
$this->updatesConstant = $updatesConstant;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
$this->fetchesConstant = $fetchesConstant;
|
||||
$this->canCreateConstant = $canCreateConstant;
|
||||
$this->createsConstant = $createsConstant;
|
||||
}
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$object = new ConstantObject($request->input('name'), $request->input('reference'), $request->input('detail'));
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
||||
|
||||
try {
|
||||
|
||||
$constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $object->getReference()]);
|
||||
$this->canUpdateConstant->passes($object);
|
||||
|
||||
/** @var SegmentConstant $constant */
|
||||
$constant = $this->updatesConstant->execute($constant, $object);
|
||||
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
|
||||
$this->canCreateConstant->passes($object);
|
||||
|
||||
/** @var SegmentConstant $constant */
|
||||
$constant = $this->createsConstant->execute($segment, $object);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $this->resourceResponse(new ConstantResource($constant));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?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\CanUpdateSegment;
|
||||
use App\Classes\Modules\Segments\Services\UpdatesSegment;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Segment',
|
||||
'message' => 'You have successfully updated the Segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateSegment */
|
||||
private $canUpdateSegment;
|
||||
|
||||
/** @var UpdatesSegment */
|
||||
private $updatesSegment;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
|
||||
/**
|
||||
* UpdateSegmentLogic constructor.
|
||||
* @param CanUpdateSegment $canUpdateSegment
|
||||
* @param UpdatesSegment $updatesSegment
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateSegment $canUpdateSegment,
|
||||
UpdatesSegment $updatesSegment,
|
||||
FetchesSegment $fetchesSegment
|
||||
)
|
||||
{
|
||||
$this->canUpdateSegment = $canUpdateSegment;
|
||||
$this->updatesSegment = $updatesSegment;
|
||||
$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')]);
|
||||
|
||||
$segment_object = new SegmentObject(
|
||||
$request->input('name', $segment_query->name)
|
||||
);
|
||||
$this->canUpdateSegment->passes($segment_object);
|
||||
$segment_query = $this->updatesSegment->execute($segment_query, $segment_object);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new SegmentResource($segment_query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
|
||||
class SegmentObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
/** @var int|null */
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* SegmentObject constructor.
|
||||
* @param string $name
|
||||
* @param int|null $type
|
||||
*/
|
||||
public function __construct(string $name, ?int $type = SegmentConstants::STANDARD_SEGMENT)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getType(): int
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Services;
|
||||
|
||||
|
||||
use App\Classes\Modules\Currencies\Services\FetchesCurrency;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Http\Resources\ConstantResource;
|
||||
use App\Http\Resources\CurrencyResource;
|
||||
use App\Models\SegmentConstant;
|
||||
|
||||
class ConvertsConstantDetailsToResource
|
||||
{
|
||||
|
||||
/** @var FetchesCurrency */
|
||||
private $fetchesCurrency;
|
||||
|
||||
/**
|
||||
* ConvertsConstantDetailsToResource constructor.
|
||||
* @param FetchesCurrency $fetchesCurrency
|
||||
*/
|
||||
public function __construct(FetchesCurrency $fetchesCurrency)
|
||||
{
|
||||
$this->fetchesCurrency = $fetchesCurrency;
|
||||
}
|
||||
|
||||
|
||||
public function execute(SegmentConstant $constant){
|
||||
|
||||
if($constant->reference === SegmentConstants::SUPPLIER_CURRENCIES) {
|
||||
return property_exists($constant->detail, 'id') ? new CurrencyResource($this->fetchesCurrency->execute(['id' => $constant->detail->id])) : '';
|
||||
}
|
||||
|
||||
return $constant->detail;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Models\Segment;
|
||||
|
||||
class CreatesSegment extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(SegmentObject $object) {
|
||||
$model = new Segment();
|
||||
$model->name = $object->getName();
|
||||
$model->type = SegmentConstants::CUSTOM_SEGMENT;
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractDeleteRecord;
|
||||
use App\Models\Segment;
|
||||
|
||||
class DeletesSegment extends AbstractDeleteRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Segment $model
|
||||
* @return mixed
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Segment $model) {
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\SegmentConstant;
|
||||
|
||||
class FetchesConstant extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var SegmentConstant */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* FetchesConstant constructor.
|
||||
* @param SegmentConstant $repository
|
||||
*/
|
||||
public function __construct(SegmentConstant $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\SegmentConstant;
|
||||
|
||||
class ListsConstants extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var SegmentConstant */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsConstants constructor.
|
||||
* @param SegmentConstant $repository
|
||||
*/
|
||||
public function __construct(SegmentConstant $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Segment;
|
||||
|
||||
class ListsSegments extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var Segment */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsSegments constructor.
|
||||
* @param Segment $repository
|
||||
*/
|
||||
public function __construct(Segment $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Models\SegmentConstant;
|
||||
|
||||
class UpdatesConstant extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param SegmentConstant $model
|
||||
* @param ConstantObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(SegmentConstant $model, ConstantObject $object)
|
||||
{
|
||||
$model->name = $object->getName();
|
||||
$model->reference = $object->getReference();
|
||||
$model->detail = json_encode($object->getDetail());
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
use App\Models\Segment;
|
||||
|
||||
class UpdatesSegment extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Segment $model
|
||||
* @param SegmentObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Segment $model, SegmentObject $object)
|
||||
{
|
||||
$model->name = $object->getName();
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Classes\Modules\Segments\Standards\Validators\ConstantValidation;
|
||||
|
||||
class CanCreateConstant extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var ConstantValidation */
|
||||
private $constantValidation;
|
||||
|
||||
/**
|
||||
* CanCreateConstant constructor.
|
||||
* @param ConstantValidation $constantValidation
|
||||
*/
|
||||
public function __construct(ConstantValidation $constantValidation)
|
||||
{
|
||||
$this->constantValidation = $constantValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConstantObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->constantValidation->validate($object, 'POST');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConstantObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
use App\Classes\Modules\Segments\Standards\Validators\SegmentValidation;
|
||||
|
||||
class CanCreateSegment extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var SegmentValidation */
|
||||
private $segmentValidation;
|
||||
|
||||
/**
|
||||
* CanCreateSegment constructor.
|
||||
* @param SegmentValidation $segmentValidation
|
||||
*/
|
||||
public function __construct(SegmentValidation $segmentValidation)
|
||||
{
|
||||
$this->segmentValidation = $segmentValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
// if (!\Auth::user()->can('add segment')) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->segmentValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
|
||||
class CanDeleteSegment extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
if (!\Auth::user()->can('delete segment')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
|
||||
class CanFetchSegment extends AbstractRule
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CompanyObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param CompanyObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
|
||||
class CanListSegments extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Classes\Modules\Segments\Standards\Validators\ConstantValidation;
|
||||
|
||||
class CanUpdateConstant extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var ConstantValidation */
|
||||
private $ConstantValidation;
|
||||
|
||||
/**
|
||||
* CanUpdateConstant constructor.
|
||||
* @param ConstantValidation $ConstantValidation
|
||||
*/
|
||||
public function __construct(ConstantValidation $ConstantValidation)
|
||||
{
|
||||
$this->ConstantValidation = $ConstantValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConstantObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->ConstantValidation->validate($object, 'PUT');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConstantObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
use App\Classes\Modules\Segments\Standards\Validators\SegmentValidation;
|
||||
|
||||
class CanUpdateSegment extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var SegmentValidation */
|
||||
private $segmentValidation;
|
||||
|
||||
|
||||
/**
|
||||
* CanUpdateSegment constructor.
|
||||
* @param SegmentValidation $segmentValidation
|
||||
*/
|
||||
public function __construct(SegmentValidation $segmentValidation)
|
||||
{
|
||||
$this->segmentValidation = $segmentValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
if (!\Auth::user()->can('edit segment')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->segmentValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Standards\Validators;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
|
||||
class ConstantValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param ConstantObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array {
|
||||
|
||||
$data = [
|
||||
'name' => $object->getName(),
|
||||
'reference' => $object->getReference(),
|
||||
'detail' => $object->getDetail()
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array {
|
||||
return [
|
||||
'name' => 'required',
|
||||
'reference' => 'required',
|
||||
'detail' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array {
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
|
||||
class SegmentValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'name' => $object->getName(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Classes\Modules\Segments\Services\CreatesConstant;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceDetailObject;
|
||||
use App\Classes\Modules\ServiceTypes\Services\CreatesServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\Services\CreatesServiceTypeConstantDetails;
|
||||
use App\Classes\Modules\ServiceTypes\Services\UpdatesServiceCurrencyRates;
|
||||
use App\Classes\Modules\ServiceTypes\Standards\Rules\CanCreateServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceTypeObject;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Http\Resources\ServiceTypeResource;
|
||||
use App\Models\ServiceType;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateServiceTypeLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Service Type',
|
||||
'message' => 'You have successfully created a new Service Type'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateServiceType */
|
||||
private $canCreateServiceType;
|
||||
|
||||
/** @var CreatesServiceType */
|
||||
private $createsServiceType;
|
||||
|
||||
/** @var CreatesServiceTypeConstantDetails */
|
||||
private $createsServiceTypeConstantDetails;
|
||||
|
||||
/** @var UpdatesServiceCurrencyRates */
|
||||
private $updatesServiceCurrencyRates;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var CreatesConstant */
|
||||
private $createsConstant;
|
||||
|
||||
|
||||
/**
|
||||
* CreateServiceTypeLogic constructor.
|
||||
* @param CanCreateServiceType $canCreateServiceType
|
||||
* @param CreatesServiceType $createsServiceType
|
||||
* @param CreatesServiceTypeConstantDetails $createsServiceTypeConstantDetails
|
||||
* @param UpdatesServiceCurrencyRates $updatesServiceCurrencyRates
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
* @param CreatesConstant $createsConstant
|
||||
*/
|
||||
public function __construct(CanCreateServiceType $canCreateServiceType, CreatesServiceType $createsServiceType, CreatesServiceTypeConstantDetails $createsServiceTypeConstantDetails, UpdatesServiceCurrencyRates $updatesServiceCurrencyRates, FetchesSegment $fetchesSegment, CreatesConstant $createsConstant)
|
||||
{
|
||||
$this->canCreateServiceType = $canCreateServiceType;
|
||||
$this->createsServiceType = $createsServiceType;
|
||||
$this->createsServiceTypeConstantDetails = $createsServiceTypeConstantDetails;
|
||||
$this->updatesServiceCurrencyRates = $updatesServiceCurrencyRates;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
$this->createsConstant = $createsConstant;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$object = new ServiceTypeObject($request->input('name'));
|
||||
|
||||
$this->canCreateServiceType->passes($object);
|
||||
|
||||
/** @var ServiceType $service */
|
||||
$service = $this->createsServiceType->execute($object);
|
||||
|
||||
$object = new ServiceDetailObject($service->id, (int) $request->input('configurations.bank_id'),
|
||||
$request->input('configurations.service_charge'), $request->input('configurations.minimum_charge'), $request->input('configurations.tax'),
|
||||
$request->input('configurations.po_limit'), $request->input('configurations.currencies'), false, $request->input('configurations.billable'));
|
||||
|
||||
$this->updatesServiceCurrencyRates->execute($service, $object->getCurrencies());
|
||||
|
||||
$constantObject = new ConstantObject('Service Type', SegmentConstants::SERVICE_TYPE, $this->createsServiceTypeConstantDetails->execute($object));
|
||||
|
||||
$this->createsConstant->execute($this->fetchesSegment->execute(['type' => SegmentConstants::STANDARD_SEGMENT]), $constantObject);
|
||||
|
||||
|
||||
return $this->resourceResponse(new ServiceTypeResource($service));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\ServiceTypes\Services\DeletesServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\Services\FetchesServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\Standards\Rules\CanDeleteServiceType;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteServiceTypeLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Deleted Service Type',
|
||||
'message' => 'You have successfully deleted a Service Type'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var CanDeleteServiceType */
|
||||
private $canDeleteServiceType;
|
||||
|
||||
/** @var DeletesServiceType */
|
||||
private $deletesServiceType;
|
||||
|
||||
/** @var FetchesServiceType */
|
||||
private $fetchesServiceType;
|
||||
|
||||
/**
|
||||
* DeleteServiceTypeLogic constructor.
|
||||
* @param CanDeleteServiceType $canDeleteServiceType
|
||||
* @param DeletesServiceType $deletesServiceType
|
||||
* @param FetchesServiceType $fetchesServiceType
|
||||
*/
|
||||
public function __construct(CanDeleteServiceType $canDeleteServiceType, DeletesServiceType $deletesServiceType, FetchesServiceType $fetchesServiceType)
|
||||
{
|
||||
$this->canDeleteServiceType = $canDeleteServiceType;
|
||||
$this->deletesServiceType = $deletesServiceType;
|
||||
$this->fetchesServiceType = $fetchesServiceType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$this->canDeleteServiceType->passes();
|
||||
|
||||
$query = $this->fetchesServiceType->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->deletesServiceType->execute($query);
|
||||
|
||||
return $this->response([]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\ServiceTypes\Services\FetchesServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\Standards\Rules\CanFetchServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceTypeObject;
|
||||
use App\Http\Resources\ServiceTypeResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchServiceTypeLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Service Type',
|
||||
'message' => 'You have successfully retrieved a Service Type'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanFetchServiceType */
|
||||
private $canFetchServiceType;
|
||||
|
||||
/** @var FetchesServiceType */
|
||||
private $fetchesServiceType;
|
||||
|
||||
/**
|
||||
* FetchServiceTypeLogic constructor.
|
||||
* @param CanFetchServiceType $canFetchServiceType
|
||||
* @param FetchesServiceType $fetchesServiceType
|
||||
*/
|
||||
public function __construct(CanFetchServiceType $canFetchServiceType, FetchesServiceType $fetchesServiceType)
|
||||
{
|
||||
$this->canFetchServiceType = $canFetchServiceType;
|
||||
$this->fetchesServiceType = $fetchesServiceType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canFetchServiceType->passes();
|
||||
|
||||
$query = $this->fetchesServiceType->execute(['id' => $request->route('id')]);
|
||||
|
||||
return $this->resourceResponse(new ServiceTypeResource($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\ServiceTypes\Services\ListsServiceTypes;
|
||||
use App\Classes\Modules\ServiceTypes\Standards\Rules\CanListServiceTypes;
|
||||
use App\Http\Resources\ServiceTypeResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListServiceTypesLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Service Types',
|
||||
'message' => 'You have successfully retrieved a list of Service Types'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanListServiceTypes */
|
||||
private $canListServiceTypes;
|
||||
|
||||
/** @var ListsServiceTypes */
|
||||
private $listsServiceTypes;
|
||||
|
||||
/**
|
||||
* ListServiceTypesControllerLogic constructor.
|
||||
* @param CanListServiceTypes $canListServiceTypes
|
||||
* @param ListsServiceTypes $listsServiceTypes
|
||||
*/
|
||||
public function __construct(CanListServiceTypes $canListServiceTypes, ListsServiceTypes $listsServiceTypes)
|
||||
{
|
||||
$this->canListServiceTypes = $canListServiceTypes;
|
||||
$this->listsServiceTypes = $listsServiceTypes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canListServiceTypes->passes();
|
||||
|
||||
$query = $this->listsServiceTypes->execute($this->listsServiceTypes->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(ServiceTypeResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Classes\Modules\Segments\Services\CreatesConstant;
|
||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\Modules\Segments\Services\UpdatesConstant;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceDetailObject;
|
||||
use App\Classes\Modules\ServiceTypes\Services\CreatesServiceTypeConstantDetails;
|
||||
use App\Classes\Modules\ServiceTypes\Services\FetchesServiceType;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Http\Resources\CustomServiceTypeResource;
|
||||
use App\Models\Segment;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCustomServiceConstantLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update Segment Service',
|
||||
'message' => 'You have successfully update a segments service configuration'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesServiceType */
|
||||
private $fetchesServiceType;
|
||||
|
||||
/** @var CreatesServiceTypeConstantDetails */
|
||||
private $createsServiceTypeConstantDetails;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var FetchesConstant */
|
||||
private $fetchesConstant;
|
||||
|
||||
/** @var UpdatesConstant */
|
||||
private $updatesConstant;
|
||||
|
||||
/** @var CreatesConstant */
|
||||
private $createsConstant;
|
||||
|
||||
/**
|
||||
* UpdateCustomServiceConstantLogic constructor.
|
||||
* @param FetchesServiceType $fetchesServiceType
|
||||
* @param CreatesServiceTypeConstantDetails $createsServiceTypeConstantDetails
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
* @param FetchesConstant $fetchesConstant
|
||||
* @param UpdatesConstant $updatesConstant
|
||||
* @param CreatesConstant $createsConstant
|
||||
*/
|
||||
public function __construct(FetchesServiceType $fetchesServiceType, CreatesServiceTypeConstantDetails $createsServiceTypeConstantDetails, FetchesSegment $fetchesSegment, FetchesConstant $fetchesConstant, UpdatesConstant $updatesConstant, CreatesConstant $createsConstant)
|
||||
{
|
||||
$this->fetchesServiceType = $fetchesServiceType;
|
||||
$this->createsServiceTypeConstantDetails = $createsServiceTypeConstantDetails;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
$this->fetchesConstant = $fetchesConstant;
|
||||
$this->updatesConstant = $updatesConstant;
|
||||
$this->createsConstant = $createsConstant;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$service = $this->fetchesServiceType->execute(['id' => $request->input('id')]);
|
||||
|
||||
$customFields = $request->input('custom_fields');
|
||||
|
||||
$object = new ServiceDetailObject($service->id, $customFields['bank_id'], $customFields['service_charge'],
|
||||
$customFields['minimum_charge'], $customFields['tax'], $customFields['po_limit'], $request->input('configurations.currencies'),
|
||||
$request->input('configurations.active'), true);
|
||||
|
||||
$constantObject = new ConstantObject('Custom Service Type', SegmentConstants::CUSTOM_SERVICE_TYPE, $this->createsServiceTypeConstantDetails->execute($object, true));
|
||||
|
||||
/** @var Segment $segment */
|
||||
$segment = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
||||
|
||||
try {
|
||||
|
||||
$constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'custom_service_type' => $object->getId()]);
|
||||
|
||||
$this->updatesConstant->execute($constant, $constantObject);
|
||||
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
|
||||
$constant = $this->createsConstant->execute($segment, $constantObject);
|
||||
}
|
||||
|
||||
|
||||
return $this->resourceResponse(new CustomServiceTypeResource($constant));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
||||
use App\Classes\Modules\Segments\Services\UpdatesConstant;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceDetailObject;
|
||||
use App\Classes\Modules\ServiceTypes\Services\CreatesServiceTypeConstantDetails;
|
||||
use App\Classes\Modules\ServiceTypes\Services\UpdatesServiceCurrencyRates;
|
||||
use App\Classes\Modules\ServiceTypes\Services\UpdatesServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\Services\FetchesServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\Standards\Rules\CanUpdateServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceTypeObject;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Http\Resources\ServiceTypeResource;
|
||||
use App\Models\ServiceType;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateServiceTypeLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Service Type',
|
||||
'message' => 'You have successfully updated the Service Type'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateServiceType */
|
||||
private $canUpdateServiceType;
|
||||
|
||||
/** @var UpdatesServiceType */
|
||||
private $updatesServiceType;
|
||||
|
||||
/** @var FetchesServiceType */
|
||||
private $fetchesServiceType;
|
||||
|
||||
/** @var CreatesServiceTypeConstantDetails */
|
||||
private $createsServiceTypeConstantDetails;
|
||||
|
||||
/** @var UpdatesServiceCurrencyRates */
|
||||
private $updatesServiceCurrencyRates;
|
||||
|
||||
/** @var UpdatesConstant */
|
||||
private $updatesConstant;
|
||||
|
||||
/** @var FetchesConstant */
|
||||
private $fetchesConstant;
|
||||
|
||||
|
||||
/**
|
||||
* UpdateServiceTypeLogic constructor.
|
||||
* @param CanUpdateServiceType $canUpdateServiceType
|
||||
* @param UpdatesServiceType $updatesServiceType
|
||||
* @param FetchesServiceType $fetchesServiceType
|
||||
* @param CreatesServiceTypeConstantDetails $createsServiceTypeConstantDetails
|
||||
* @param UpdatesServiceCurrencyRates $updatesServiceCurrencyRates
|
||||
* @param UpdatesConstant $updatesConstant
|
||||
* @param FetchesConstant $fetchesConstant
|
||||
*/
|
||||
public function __construct(CanUpdateServiceType $canUpdateServiceType, UpdatesServiceType $updatesServiceType, FetchesServiceType $fetchesServiceType, CreatesServiceTypeConstantDetails $createsServiceTypeConstantDetails, UpdatesServiceCurrencyRates $updatesServiceCurrencyRates, UpdatesConstant $updatesConstant, FetchesConstant $fetchesConstant)
|
||||
{
|
||||
$this->canUpdateServiceType = $canUpdateServiceType;
|
||||
$this->updatesServiceType = $updatesServiceType;
|
||||
$this->fetchesServiceType = $fetchesServiceType;
|
||||
$this->createsServiceTypeConstantDetails = $createsServiceTypeConstantDetails;
|
||||
$this->updatesServiceCurrencyRates = $updatesServiceCurrencyRates;
|
||||
$this->updatesConstant = $updatesConstant;
|
||||
$this->fetchesConstant = $fetchesConstant;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new ServiceTypeObject($request->input('name'));
|
||||
|
||||
$this->canUpdateServiceType->passes($object);
|
||||
|
||||
$service = $this->fetchesServiceType->execute(['id' => $request->route('id')]);
|
||||
|
||||
/** @var ServiceType $service */
|
||||
$service = $this->updatesServiceType->execute($service, $object);
|
||||
|
||||
$object = new ServiceDetailObject($service->id, (int) $request->input('configurations.bank_id'),
|
||||
$request->input('configurations.service_charge'), $request->input('configurations.minimum_charge'), $request->input('configurations.tax'),
|
||||
$request->input('configurations.po_limit'), $request->input('configurations.currencies'), $request->input('configurations.active'), $request->input('configurations.billable'));
|
||||
|
||||
$this->updatesServiceCurrencyRates->execute($service, $object->getCurrencies());
|
||||
|
||||
$constantObject = new ConstantObject('Service Type', SegmentConstants::SERVICE_TYPE, $this->createsServiceTypeConstantDetails->execute($object));
|
||||
|
||||
$this->updatesConstant->execute($this->fetchesConstant->execute(['service_type' => $service->id]), $constantObject);
|
||||
|
||||
return $this->resourceResponse(new ServiceTypeResource($service));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\ServiceTypes\Services\FetchesServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\Services\UpdatesServiceTypeStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateServiceTypeStatusLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update Service Type',
|
||||
'message' => 'You have successfully updated a Service Type status'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesServiceType */
|
||||
private $fetchesServiceType;
|
||||
|
||||
/** @var UpdatesServiceTypeStatus */
|
||||
private $updatesServiceTypeStatus;
|
||||
|
||||
/**
|
||||
* UpdateServiceTypeStatusLogic constructor.
|
||||
* @param FetchesServiceType $fetchesServiceType
|
||||
* @param UpdatesServiceTypeStatus $updatesServiceTypeStatus
|
||||
*/
|
||||
public function __construct(FetchesServiceType $fetchesServiceType, UpdatesServiceTypeStatus $updatesServiceTypeStatus)
|
||||
{
|
||||
$this->fetchesServiceType = $fetchesServiceType;
|
||||
$this->updatesServiceTypeStatus = $updatesServiceTypeStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
|
||||
$query = $this->fetchesServiceType->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->updatesServiceTypeStatus->execute($query, $request->route('status') === 'active' ? ApprovalStatus::APPROVED : ApprovalStatus::SUSPENDED);
|
||||
|
||||
return $this->response([]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\DataTransferObjects;
|
||||
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Classes\Modules\ServiceTypes\Services\FetchesServiceCurrenciesConfigurations;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Models\SegmentConstant;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class CustomConfigurationsObject implements DataTransferObject
|
||||
{
|
||||
|
||||
|
||||
/** @var SegmentConstant */
|
||||
private $configurations;
|
||||
|
||||
/** @var SegmentConstant */
|
||||
private $customOptions;
|
||||
|
||||
/**
|
||||
* CustomConfigurationsObject constructor.
|
||||
* @param SegmentConstant $configurations
|
||||
* @param SegmentConstant $customOptions
|
||||
*/
|
||||
public function __construct(SegmentConstant $configurations, SegmentConstant $customOptions)
|
||||
{
|
||||
$this->configurations = $configurations;
|
||||
$this->customOptions = $customOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SegmentConstant
|
||||
*/
|
||||
public function getConfigurations(): SegmentConstant
|
||||
{
|
||||
return $this->configurations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SegmentConstant
|
||||
*/
|
||||
public function getCustomOptions(): SegmentConstant
|
||||
{
|
||||
return $this->customOptions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfigurationValue(string $name) {
|
||||
return property_exists($this->getCustomOptions()->detail, $name) ?
|
||||
$this->getCustomOptions()->detail->$name: $this->configurations->detail->$name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function calculateServiceCharge(){
|
||||
return ($this->getConfigurationValue('service_charge')->value * 0.01) > $this->getConfigurationValue('minimum_charge')->value ?
|
||||
$this->getConfigurationValue('service_charge')->value : $this->getConfigurationValue('minimum_charge')->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function calculateTax(){
|
||||
return $this->getConfigurationValue('tax')->value * 0.01;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Classes\Modules\Currencies\DataTransferObjects\RateObject;
|
||||
|
||||
class ServiceCurrenciesObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var int */
|
||||
private $id;
|
||||
|
||||
/** @var boolean */
|
||||
private $isActive;
|
||||
|
||||
/** @var array */
|
||||
private $maxLimit;
|
||||
|
||||
/** @var array */
|
||||
private $minLimit;
|
||||
|
||||
/** @var array */
|
||||
private $rates;
|
||||
|
||||
/**
|
||||
* ServiceCurrenciesObject constructor.
|
||||
* @param int $id
|
||||
* @param bool $isActive
|
||||
* @param array $maxLimit
|
||||
* @param array $minLimit
|
||||
* @param array $rates
|
||||
*/
|
||||
public function __construct(int $id, bool $isActive, array $maxLimit, array $minLimit, array $rates)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->isActive = $isActive;
|
||||
$this->maxLimit = $maxLimit;
|
||||
$this->minLimit = $minLimit;
|
||||
$this->rates = $rates;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->isActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getMaxLimit(): array
|
||||
{
|
||||
return $this->maxLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getMinLimit(): array
|
||||
{
|
||||
return $this->minLimit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getRates(): array
|
||||
{
|
||||
return array_map(function($rate){
|
||||
return new RateObject($rate['selling'], $rate['payment_method']);
|
||||
}, $this->rates);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class ServiceDetailObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var int */
|
||||
private $id;
|
||||
|
||||
/** @var int|null */
|
||||
private $bankId;
|
||||
|
||||
/** @var array|null */
|
||||
private $serviceCharge;
|
||||
|
||||
/** @var array|null */
|
||||
private $minimumCharge;
|
||||
|
||||
/** @var array|null */
|
||||
private $tax;
|
||||
|
||||
/** @var array|null */
|
||||
private $poLimit;
|
||||
|
||||
/** @var array|null */
|
||||
private $currencies;
|
||||
|
||||
/** @var boolean */
|
||||
private $isActive;
|
||||
|
||||
/** @var boolean */
|
||||
private $isBillable;
|
||||
|
||||
/**
|
||||
* ServiceDetailObject constructor.
|
||||
* @param int $id
|
||||
* @param int|null $bankId
|
||||
* @param array|null $serviceCharge
|
||||
* @param array|null $minimumCharge
|
||||
* @param array|null $tax
|
||||
* @param array|null $poLimit
|
||||
* @param array|null $currencies
|
||||
* @param bool $isActive
|
||||
* @param bool $isBillable
|
||||
*/
|
||||
public function __construct(int $id, ?int $bankId, ?array $serviceCharge, ?array $minimumCharge, ?array $tax, ?array $poLimit, ?array $currencies, bool $isActive, bool $isBillable)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->bankId = $bankId;
|
||||
$this->serviceCharge = $serviceCharge;
|
||||
$this->minimumCharge = $minimumCharge;
|
||||
$this->tax = $tax;
|
||||
$this->poLimit = $poLimit;
|
||||
$this->currencies = $currencies;
|
||||
$this->isActive = $isActive;
|
||||
$this->isBillable = $isBillable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getBankId(): ?int
|
||||
{
|
||||
return $this->bankId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getServiceCharge(): ?array
|
||||
{
|
||||
return $this->serviceCharge;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getMinimumCharge(): ?array
|
||||
{
|
||||
return $this->minimumCharge;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getTax(): ?array
|
||||
{
|
||||
return $this->tax;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getPoLimit(): ?array
|
||||
{
|
||||
return $this->poLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->isActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isBillable(): bool
|
||||
{
|
||||
return $this->isBillable;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getCurrencies(): ?array
|
||||
{
|
||||
return array_map(function($currency){
|
||||
return new ServiceCurrenciesObject($currency['id'], $currency['active'], $currency['maximum_limit'], $currency['minimum_limit'], $currency['rates']);
|
||||
}, $this->currencies);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\DataTransferObjects;
|
||||
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class ServiceTypeObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* ServiceTypeObject constructor.
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceTypeObject;
|
||||
use App\Models\ServiceType;
|
||||
|
||||
class CreatesServiceType extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
public function execute(ServiceTypeObject $object) {
|
||||
$model = new ServiceType();
|
||||
$model->name = $object->getName();
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Helper;
|
||||
use App\Classes\Modules\Currencies\DataTransferObjects\RateObject;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceCurrenciesObject;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceDetailObject;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreatesServiceTypeConstantDetails
|
||||
{
|
||||
|
||||
/** @var array */
|
||||
private $ConstantDetails;
|
||||
|
||||
|
||||
/**
|
||||
* @param ServiceDetailObject $object
|
||||
* @param bool|null $isCustomSegment
|
||||
* @return array
|
||||
*/
|
||||
public function execute(ServiceDetailObject $object, ?bool $isCustomSegment = false) {
|
||||
|
||||
foreach (Helper::getClassMethodsArray(ServiceDetailObject::class) as $methodName){
|
||||
|
||||
if(Helper::getPropertyName($methodName) === 'currencies'){
|
||||
|
||||
$this->mapCurrencies($object->$methodName(), $isCustomSegment);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->addToConstantDetails($methodName, $this->cleanValue($object->$methodName()));
|
||||
|
||||
}
|
||||
|
||||
return $this->ConstantDetails;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $currencies
|
||||
* @param bool $isCustomSegment
|
||||
*/
|
||||
private function mapCurrencies(array $currencies, bool $isCustomSegment){
|
||||
|
||||
$isEmpty = true;
|
||||
foreach ($currencies as $currency){
|
||||
|
||||
if(!$currency->isActive()) { continue; }
|
||||
|
||||
$currencyObject = [];
|
||||
|
||||
|
||||
foreach (Helper::getClassMethodsArray(ServiceCurrenciesObject::class) as $methodName){
|
||||
|
||||
if($methodName === 'isActive') continue;
|
||||
if($methodName === 'getRates') {
|
||||
$currencyObject['rates'] = $this->mapRates($currency->$methodName(), $isCustomSegment);
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = $this->cleanValue($currency->$methodName());
|
||||
|
||||
if($this->isAddable($value)) {
|
||||
$isEmpty = false;
|
||||
$currencyObject[Helper::getPropertyName($methodName)] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->addToCurrencyDetails($currencyObject);
|
||||
|
||||
}
|
||||
|
||||
if($isEmpty) $this->ConstantDetails['currencies'] = [];
|
||||
|
||||
}
|
||||
|
||||
private function mapRates(array $rates, bool $isCustomSegment){
|
||||
|
||||
if(!$isCustomSegment) return [];
|
||||
|
||||
$ratesObject = [];
|
||||
|
||||
/** @var RateObject $rate */
|
||||
foreach ($rates as $rate){
|
||||
|
||||
$selling = $this->cleanValue($rate->getSelling());
|
||||
|
||||
if(!$selling['value']) continue;
|
||||
|
||||
$ratesObject[] = [
|
||||
'payment_type' => $rate->getPaymentMethodType(),
|
||||
'payment_method' => PaymentMethodType::PAYMENT_METHODS_ID[$rate->getPaymentMethodType()],
|
||||
'selling' => $rate->getSelling()
|
||||
];
|
||||
|
||||
}
|
||||
return $ratesObject;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $methodName
|
||||
* @param $value
|
||||
*/
|
||||
private function addToConstantDetails(string $methodName, $value){
|
||||
$this->isAddable($value) ? $this->ConstantDetails[Helper::getPropertyName($methodName)] = $value : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @return bool
|
||||
*/
|
||||
private function isAddable($value){
|
||||
|
||||
return $value !== '' && $value !== null;
|
||||
}
|
||||
|
||||
private function cleanValue($value){
|
||||
|
||||
if(is_array($value)) {
|
||||
if(array_key_exists('value', $value)) $value['value'] = floatval(str_replace(',', '', $value['value']));
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $value
|
||||
*/
|
||||
private function addToCurrencyDetails(array $value){
|
||||
$this->ConstantDetails['currencies'][] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractDeleteRecord;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceTypeObject;
|
||||
use App\Models\ServiceType;
|
||||
|
||||
class DeletesServiceType extends AbstractDeleteRecord
|
||||
{
|
||||
|
||||
public function execute(ServiceType $model) {
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\Services;
|
||||
|
||||
use App\Classes\Modules\Banks\Services\FetchesBank;
|
||||
use App\Models\SegmentConstant;
|
||||
|
||||
class FetchesServiceBankConfigurations
|
||||
{
|
||||
|
||||
/** @var FetchesBank */
|
||||
private $fetchesBank;
|
||||
|
||||
/**
|
||||
* FetchesServiceBankConfigurations constructor.
|
||||
* @param FetchesBank $fetchesBank
|
||||
*/
|
||||
public function __construct(FetchesBank $fetchesBank)
|
||||
{
|
||||
$this->fetchesBank = $fetchesBank;
|
||||
}
|
||||
|
||||
public function execute(SegmentConstant $constants)
|
||||
{
|
||||
return $this->fetchesBank->execute(['id' => $constants->detail->bank_id]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\Services;
|
||||
|
||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
||||
use App\Models\SegmentConstant;
|
||||
|
||||
class FetchesServiceConfigurations
|
||||
{
|
||||
|
||||
/** @var FetchesConstant */
|
||||
private $fetchesConstant;
|
||||
|
||||
/** @var FetchesServiceCurrenciesConfigurations */
|
||||
private $fetchesServiceCurrenciesConfigurations;
|
||||
|
||||
/** @var FetchesServiceBankConfigurations */
|
||||
private $fetchesServiceBankConfigurations;
|
||||
|
||||
/**
|
||||
* FetchesServiceConfigurations constructor.
|
||||
* @param FetchesConstant $fetchesConstant
|
||||
* @param FetchesServiceCurrenciesConfigurations $fetchesServiceCurrenciesConfigurations
|
||||
*/
|
||||
public function __construct(FetchesConstant $fetchesConstant, FetchesServiceCurrenciesConfigurations $fetchesServiceCurrenciesConfigurations, FetchesServiceBankConfigurations $fetchesServiceBankConfigurations)
|
||||
{
|
||||
$this->fetchesConstant = $fetchesConstant;
|
||||
$this->fetchesServiceCurrenciesConfigurations = $fetchesServiceCurrenciesConfigurations;
|
||||
$this->fetchesServiceBankConfigurations = $fetchesServiceBankConfigurations;
|
||||
}
|
||||
|
||||
|
||||
public function execute(SegmentConstant $constant, string $type){
|
||||
|
||||
return array_merge([
|
||||
'active' => (int) $constant->detail->is_active ?? false,
|
||||
'billable' => (int) $constant->detail->is_billable ?? false,
|
||||
'bank_id' => property_exists($constant->detail, 'bank_id') ? $constant->detail->bank_id : '',
|
||||
'bank_info' => property_exists($constant->detail, 'bank_id') ? $this->fetchesServiceBankConfigurations->execute($constant) : '',
|
||||
'currencies' => $this->fetchesServiceCurrenciesConfigurations->execute($constant)
|
||||
], $this->addConfigurations($constant)->toArray());
|
||||
|
||||
}
|
||||
|
||||
private function addConfigurations(SegmentConstant $constant) {
|
||||
|
||||
$configurations = collect(['service_charge', 'minimum_charge', 'tax', 'po_limit']);
|
||||
|
||||
return $configurations->flatMap(function($configuration) use($constant) {
|
||||
if(!property_exists($constant->detail, $configuration)) return [];
|
||||
|
||||
return [$configuration => [
|
||||
'type' => $constant->detail->$configuration->type,
|
||||
'value' => $configuration !== 'po_limit' ? $this->covertToDecimal($constant->detail->$configuration->value) : $constant->detail->$configuration->value
|
||||
]];
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private function covertToDecimal($value){
|
||||
return number_format((float)$value, 2, '.', '');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\Services;
|
||||
|
||||
|
||||
use App\Classes\Modules\Currencies\Services\FetchesCurrency;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Http\Resources\CurrencyResource;
|
||||
use App\Models\SegmentConstant;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class FetchesServiceCurrenciesConfigurations
|
||||
{
|
||||
|
||||
/** @var FetchesCurrency */
|
||||
private $fetchesCurrency;
|
||||
|
||||
/**
|
||||
* FetchesServiceCurrenciesConfigurations constructor.
|
||||
* @param FetchesCurrency $fetchesCurrency
|
||||
*/
|
||||
public function __construct(FetchesCurrency $fetchesCurrency)
|
||||
{
|
||||
$this->fetchesCurrency = $fetchesCurrency;
|
||||
}
|
||||
|
||||
public function execute(SegmentConstant $constants){
|
||||
|
||||
$currencies = array_map(function($configuration) use($constants){
|
||||
|
||||
$currency = $this->fetchesCurrency->execute(['id' => $configuration->id]);
|
||||
|
||||
if(! $currency->exists()) return [];
|
||||
|
||||
return json_decode(json_encode([
|
||||
'currency_object' => new CurrencyResource($currency),
|
||||
'id' => $configuration->id,
|
||||
'active' => true,
|
||||
'maximum_limit' => [
|
||||
'type' => $configuration->max_limit->type,
|
||||
'value' => number_format((float)$configuration->max_limit->value, 2, '.', ',')
|
||||
],
|
||||
'minimum_limit' => [
|
||||
'type' => $configuration->min_limit->type,
|
||||
'value' => number_format((float)$configuration->min_limit->value, 2, '.', ',')
|
||||
],
|
||||
'rates' => $constants->reference === SegmentConstants::SERVICE_TYPE ? $this->standardRates($currency->rates->where('service_id', $constants->detail->id)) : $configuration->rates
|
||||
]));
|
||||
|
||||
}, $constants->detail->currencies);
|
||||
|
||||
return array_filter($currencies);
|
||||
|
||||
}
|
||||
|
||||
private function standardRates(Collection $rates){
|
||||
return $rates->map(function($rate){
|
||||
return [
|
||||
'payment_method' => PaymentMethodType::PAYMENT_METHODS_ID[$rate->payment_method_type],
|
||||
'selling' => [
|
||||
'type' => 'rate',
|
||||
'value' => $rate->selling
|
||||
]
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\ServiceType;
|
||||
|
||||
class FetchesServiceType extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var ServiceType */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* FetchesServiceType constructor.
|
||||
* @param ServiceType $repository
|
||||
*/
|
||||
public function __construct(ServiceType $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\ServiceType;
|
||||
|
||||
class ListsServiceTypes extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var ServiceType */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsServiceTypes constructor.
|
||||
* @param ServiceType $repository
|
||||
*/
|
||||
public function __construct(ServiceType $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\Services;
|
||||
|
||||
|
||||
use App\Classes\Modules\Currencies\DataTransferObjects\RateObject;
|
||||
use App\Classes\Modules\Currencies\Services\Rates\CreatesRateLog;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceCurrenciesObject;
|
||||
use App\Models\CurrencyRate;
|
||||
use App\Models\ServiceType;
|
||||
|
||||
class UpdatesServiceCurrencyRates
|
||||
{
|
||||
|
||||
/** @var CreatesRateLog */
|
||||
private $createsRateLog;
|
||||
|
||||
/**
|
||||
* UpdatesServiceCurrencyRates constructor.
|
||||
* @param CreatesRateLog $createsRateLog
|
||||
*/
|
||||
public function __construct(CreatesRateLog $createsRateLog)
|
||||
{
|
||||
$this->createsRateLog = $createsRateLog;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ServiceType $service
|
||||
* @param array $currencies
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(ServiceType $service, array $currencies){
|
||||
|
||||
/** @var ServiceCurrenciesObject $currency */
|
||||
foreach ($currencies as $currency) {
|
||||
|
||||
/** @var RateObject $rate */
|
||||
foreach ($currency->getRates() as $rate){
|
||||
if($rate->getSelling()['value'] > 0){
|
||||
/** @var CurrencyRate $query */
|
||||
$query = $service->rates()->updateOrCreate([
|
||||
'currency_id' => $currency->getId(),
|
||||
'payment_method_type' => $rate->getPaymentMethodType()
|
||||
], ['selling' => $rate->getSelling()['value']]);
|
||||
|
||||
$this->createsRateLog->execute($query);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceTypeObject;
|
||||
use App\Models\ServiceType;
|
||||
|
||||
class UpdatesServiceType extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
public function execute(ServiceType $model, ServiceTypeObject $object) {
|
||||
|
||||
$model->name = $object->getName();
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceTypeObject;
|
||||
use App\Models\ServiceType;
|
||||
|
||||
class UpdatesServiceTypeStatus extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
public function execute(ServiceType $model, int $status) {
|
||||
|
||||
$model->status = $status;
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceTypeObject;
|
||||
use App\Classes\Modules\ServiceTypes\Standards\Validators\ServiceTypeValidation;
|
||||
|
||||
class CanCreateServiceType extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var ServiceTypeValidation */
|
||||
private $serviceTypeValidation;
|
||||
|
||||
/**
|
||||
* CanCreateServiceType constructor.
|
||||
* @param ServiceTypeValidation $serviceTypeValidation
|
||||
*/
|
||||
public function __construct(ServiceTypeValidation $serviceTypeValidation)
|
||||
{
|
||||
$this->serviceTypeValidation = $serviceTypeValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ServiceTypeObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->serviceTypeValidation->validate($object);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ServiceTypeObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceTypeObject;
|
||||
|
||||
class CanDeleteServiceType extends AbstractRule
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ServiceTypeObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ServiceTypeObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceTypeObject;
|
||||
|
||||
class CanFetchServiceType extends AbstractRule
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ServiceTypeObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ServiceTypeObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceTypeObject;
|
||||
|
||||
class CanListServiceTypes extends AbstractRule
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ServiceTypeObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ServiceTypeObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceTypeObject;
|
||||
use App\Classes\Modules\ServiceTypes\Standards\Validators\ServiceTypeValidation;
|
||||
|
||||
class CanUpdateServiceType extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var ServiceTypeValidation */
|
||||
private $serviceTypeValidation;
|
||||
|
||||
/**
|
||||
* CanUpdateServiceType constructor.
|
||||
* @param ServiceTypeValidation $serviceTypeValidation
|
||||
*/
|
||||
public function __construct(ServiceTypeValidation $serviceTypeValidation)
|
||||
{
|
||||
$this->serviceTypeValidation = $serviceTypeValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ServiceTypeObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->serviceTypeValidation->validate($object);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ServiceTypeObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\Standards\Validators;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceTypeObject;
|
||||
|
||||
class ServiceTypeValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param ServiceTypeObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array {
|
||||
return [
|
||||
'name' => $object->getName()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array {
|
||||
return [
|
||||
'name' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array {
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Announcements;
|
||||
|
||||
use App\Classes\Modules\Announcements\ControllersLogic\AssignAnnouncementToSegmentLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignAnnouncementToSegmentController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param AssignCompanyToSegmentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function assign(Request $request, AssignAnnouncementToSegmentLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Announcements;
|
||||
|
||||
use App\Classes\Modules\Announcements\ControllersLogic\CreateAnnouncementLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateAnnouncementController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CreateAnnouncementLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, CreateAnnouncementLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Announcements;
|
||||
|
||||
use App\Classes\Modules\Announcements\ControllersLogic\DeleteAnnouncementLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteAnnouncementController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param DeleteAnnouncementLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function delete(Request $request, DeleteAnnouncementLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Announcements;
|
||||
|
||||
use App\Classes\Modules\Announcements\ControllersLogic\ListAnnouncementsLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListAnnouncementsController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ListAnnouncementsLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function list(Request $request, ListAnnouncementsLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Announcements;
|
||||
|
||||
use App\Classes\Modules\Announcements\ControllersLogic\RemoveSegmentFromAnnouncementLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RemoveSegmentFromAnnouncementController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param RemoveCompanyFromSegmentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function detach(Request $request, RemoveSegmentFromAnnouncementLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Announcements;
|
||||
|
||||
use App\Classes\Modules\Announcements\ControllersLogic\UpdateAnnouncementLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateAnnouncementController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateAnnouncementLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateAnnouncementLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Companies;
|
||||
|
||||
use App\Classes\Modules\Accounts\ControllersLogic\AddNewMemberLogic;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AddNewMemberController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param AddNewMemberLogic $execute
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, AddNewMemberLogic $execute) : JsonResponse
|
||||
{
|
||||
return $execute->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\PackingLists\Containers;
|
||||
|
||||
use App\Classes\Modules\PackingLists\ControllersLogic\Containers\CreateContainerRemarkLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateContainerRemarkController
|
||||
{
|
||||
|
||||
public function create(Request $request, CreateContainerRemarkLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\PackingLists\Packages;
|
||||
|
||||
use App\Classes\Modules\PackingLists\ControllersLogic\Packages\CreatePackageRemarkLogic;
|
||||
use App\Classes\Modules\PackingLists\ControllersLogic\Packages\CreatePackageLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -10,10 +10,10 @@ class CreatePackageController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CreatePackageRemarkLogic $logic
|
||||
* @param CreatePackageLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, CreatePackageRemarkLogic $logic): JsonResponse {
|
||||
public function create(Request $request, CreatePackageLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\PackingLists\Packages;
|
||||
|
||||
use App\Classes\Modules\PackingLists\ControllersLogic\Packages\CreatePackageRemarkLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreatePackageRemarkController
|
||||
{
|
||||
public function create(Request $request, CreatePackageRemarkLogic $logic) : JsonResponse{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -5,18 +5,15 @@ namespace App\Http\Controllers\Reports;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Response\ApiResponseObject;
|
||||
use App\Models\CompanyConnection;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Container;
|
||||
use App\Models\Order;
|
||||
use App\Models\Package;
|
||||
use App\Models\PackingList;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MonthlyReportController
|
||||
{
|
||||
@@ -77,6 +74,50 @@ class MonthlyReportController
|
||||
]]))->handler();
|
||||
}
|
||||
|
||||
public function profitModelReport(Request $request): JsonResponse {
|
||||
$from = $request->route('from') ? Carbon::parse($request->route('from')) : Carbon::now()->startOfMonth();
|
||||
$to = $request->route('to') ? Carbon::parse($request->route('to')) : Carbon::now()->endOfMonth();
|
||||
$model = (int) $request->route('model');
|
||||
$value = (float) $request->route('value');
|
||||
|
||||
|
||||
$containers = Container::whereBetween('loading_date', [$from, $to])->orderBy('loading_date')->get();
|
||||
|
||||
$packages = $containers->flatMap(function ($container) {
|
||||
return $container->packages;
|
||||
});
|
||||
|
||||
$totalCbm = $packages->sum(function($package){
|
||||
return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity;
|
||||
});
|
||||
|
||||
$projectedCbm = $packages->sum(function($package) use ($value, $model) {
|
||||
|
||||
if($model === 2){
|
||||
return (( (float) ($package->width + ($package->width * ($value/100))) / 100) * ( (float) ($package->length + ($package->length * ($value/100))) / 100) * ( (float) ($package->height + ($package->height * ($value/100))) / 100)) * $package->quantity;
|
||||
}
|
||||
|
||||
if($model === 3){
|
||||
return ((( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) + $value) * $package->quantity;
|
||||
}
|
||||
|
||||
if($model === 4){
|
||||
$packageCbm = (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100));
|
||||
return ( $packageCbm + ($packageCbm * ($value/100))) * $package->quantity;
|
||||
}
|
||||
|
||||
return (( (float) ($package->width + $value) / 100) * ( (float) ($package->length + $value) / 100) * ( (float) ($package->height + $value) / 100)) * $package->quantity;
|
||||
|
||||
});
|
||||
|
||||
return (new ApiResponseObject('fetch monthly report Successful',
|
||||
'',
|
||||
HttpStatus::OK_WITH_MESSAGE, ['data' => [
|
||||
'total_cbm' => $totalCbm,
|
||||
'projected_cbm' => $projectedCbm,
|
||||
]]))->handler();
|
||||
}
|
||||
|
||||
public function customerReport(Request $request): JsonResponse {
|
||||
|
||||
$connection = CompanyConnection::where('invitee_reference', $request->route('marking'))->firstOrFail();
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Segments;
|
||||
|
||||
use App\Classes\Modules\Segments\ControllersLogic\CreateSegmentLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateSegmentController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CreateSegmentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, CreateSegmentLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Segments;
|
||||
|
||||
use App\Classes\Modules\Segments\ControllersLogic\DeleteSegmentLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteSegmentController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param DeleteSegmentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function delete(Request $request, DeleteSegmentLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Segments;
|
||||
|
||||
use App\Classes\Modules\Segments\ControllersLogic\FetchConstantLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchConstantController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param FetchConstantLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function fetch(Request $request, FetchConstantLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Segments;
|
||||
|
||||
use App\Classes\Modules\Segments\ControllersLogic\FetchSegmentLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchSegmentController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param FetchSegmentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function fetch(Request $request, FetchSegmentLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Segments;
|
||||
|
||||
use App\Classes\Modules\Segments\ControllersLogic\ListSegmentLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListSegmentsController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ListSegmentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function list(Request $request, ListSegmentLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Segments;
|
||||
|
||||
use App\Classes\Modules\Segments\ControllersLogic\UpdateConstantLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateConstantController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateConstantLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateConstantLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Segments;
|
||||
|
||||
use App\Classes\Modules\ServiceTypes\ControllersLogic\UpdateCustomServiceConstantLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCustomServiceConstantController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateCustomServiceConstantLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateCustomServiceConstantLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Segments;
|
||||
|
||||
use App\Classes\Modules\Segments\ControllersLogic\UpdateSegmentLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateSegmentController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateSegmentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateSegmentLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\Modules\Segments\Services\ConvertsConstantDetailsToResource;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ConstantResource extends JsonResource
|
||||
{
|
||||
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'reference' => $this->reference,
|
||||
'detail' => (App()->make(ConvertsConstantDetailsToResource::class))->execute($this->resource)
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\Modules\ServiceTypes\Services\FetchesServiceConfigurations;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Models\ServiceType;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CustomServiceTypeResource extends JsonResource
|
||||
{
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->detail->id,
|
||||
'name' => ServiceType::where('id', $this->detail->id)->first()->name,
|
||||
'detail' => $this->detail,
|
||||
'configurations' => (App()->make(FetchesServiceConfigurations::class))->execute($this->resource, SegmentConstants::CUSTOM_SERVICE_TYPE)
|
||||
];
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user