mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0bbf0f9138 | |||
| 2c39c66a2d | |||
| a56b5c64ba | |||
| 86401cdad6 | |||
| 558868d859 | |||
| 149029bc24 | |||
| ab84ca4719 | |||
| 6a4e2926b9 |
@@ -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 [];
|
||||
}
|
||||
}
|
||||
@@ -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,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)
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class Announcement
|
||||
* @package App\Models
|
||||
*
|
||||
*/
|
||||
class Announcement extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'announcements';
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
**/
|
||||
public function segments(): BelongsToMany
|
||||
{
|
||||
return $this->BelongsToMany(Segment::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row m-b-15" v-for="(item, index) in serviceCurrencies" v-bind:key="item.id">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col-3 b-a pointer p-t-20 p-b-20" :class="[{'b-success': item.active}, {'b-grey': !item.active}]" @click="item.active = !item.active">
|
||||
<div class="absolute" style="top: -10px; right: -27px;" v-if="item.active">
|
||||
<div class="icon-thumbnail icon-25 bg-success text-white btn-rounded fs-10">
|
||||
<i class="fa fs-10 fa-check"></i>
|
||||
</div>
|
||||
</div>
|
||||
<currency-component :deleteable="false" :section="section" :data="item.currency_object"></currency-component>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="row h-100 m-r-0 align-items-end" v-show="item.active">
|
||||
<div class="col p-t-15 b-t b-r b-success bg-master-lightest">
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
<div class="font-heading all-caps fs-10 hint-text muted">
|
||||
Purchase Limits
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-r-0">
|
||||
<div class="col m-r-10 p-r-5">
|
||||
<div class="row">
|
||||
<div class="col p-r-0">
|
||||
<validation-wrapper-component class="no-border" :validator="$v.parameters.currencies.$each[index].minimum_limit.value">
|
||||
<label>Minimum Limit</label>
|
||||
<input type="text" class="form-control" v-model.lazy="item.minimum_limit.value" v-money="money" :disabled="!item.active">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col-auto bg-white b-t b-r b-b b-grey">
|
||||
<div class="row h-100 align-items-center">
|
||||
<div class="col">
|
||||
<div class="font-heading fs-10 muted">{{item.currency_object.short_code}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="row">
|
||||
<div class="col p-r-0">
|
||||
<validation-wrapper-component :validator="$v.parameters.currencies.$each[index].maximum_limit.value">
|
||||
<label>Maximum Limit</label>
|
||||
<input type="text" class="form-control" v-model.lazy="item.maximum_limit.value" v-money="money" :disabled="!item.active">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col-auto bg-white b-t b-r b-b b-grey">
|
||||
<div class="row h-100 align-items-center">
|
||||
<div class="col">
|
||||
<div class="font-heading fs-10 muted">{{item.currency_object.short_code}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-r-0" v-show="item.active">
|
||||
<div class="col p-b-15 bg-master-lightest b-r b-b b-l b-success">
|
||||
<div class="row">
|
||||
<div class="col p-r-25 p-l-25">
|
||||
<div class="row m-b-10 m-t-10">
|
||||
<div class="col p-l-5">
|
||||
<div class="font-heading all-caps fs-10 hint-text muted">
|
||||
Exchange Rates
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4 p-l-5 p-r-5 m-b-10" v-for="(rate, method) in item.rates">
|
||||
<validation-wrapper-component :validator="$v.parameters.currencies.$each[index].rates.$each[method].selling.value" :class="[{'hint-text': rate.payment_method === 'wallet' || rate.payment_method === 'payment gateway'}]">
|
||||
<label class="all-caps">{{rate.payment_method}}</label>
|
||||
<input type="text" class="form-control" v-model.lazy="rate.selling.value" v-money="exchangeRate" :disabled="!item.active || rate.payment_method === 'wallet' || rate.payment_method === 'payment gateway'">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import formHandler from "../../../general/mixins/formHandler";
|
||||
import { required, requiredIf, minValue, maxValue, decimal} from "vuelidate/lib/validators";
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
parameters: {
|
||||
currencies: []
|
||||
}
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
parameters: {
|
||||
currencies: {
|
||||
$each: {
|
||||
maximum_limit: {
|
||||
value:{
|
||||
required: requiredIf(function (currency) { return currency.active}),
|
||||
}
|
||||
},
|
||||
minimum_limit: {
|
||||
value:{
|
||||
required: requiredIf(function (currency) { return currency.active })
|
||||
}
|
||||
},
|
||||
rates: {
|
||||
required: true,
|
||||
$each: {
|
||||
selling: {
|
||||
value:{
|
||||
required: requiredIf(function (currency) { return currency.active }),
|
||||
minValue: minValue(0)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
convertibleCurrencies() {
|
||||
let vm = this;
|
||||
return this.$store.getters.getListData('convertibleCurrenciesSection').forEach(function(value){
|
||||
vm.addInactiveCurrency(value)
|
||||
});
|
||||
},
|
||||
serviceCurrencies: function(){
|
||||
return this.data.currencies;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
convertibleCurrencies(){
|
||||
this.convertibleCurrencies();
|
||||
},
|
||||
serviceCurrencies(currencies){
|
||||
this.$emit('input', currencies)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
inArray(element){
|
||||
return this.parameters.currencies.some(currency => currency.id === element.id);
|
||||
},
|
||||
pushIfNotExist(element){
|
||||
if (!this.inArray(element)) {
|
||||
this.parameters.currencies.push(element);
|
||||
}
|
||||
},
|
||||
addInactiveCurrency(element){
|
||||
this.pushIfNotExist({
|
||||
currency_object: element,
|
||||
active: false,
|
||||
id: element.id,
|
||||
maximum_limit: {
|
||||
type: 'fixed_amount',
|
||||
value: 0
|
||||
},
|
||||
minimum_limit: {
|
||||
type: 'fixed_amount',
|
||||
value: 0
|
||||
},
|
||||
rates: [
|
||||
{
|
||||
payment_method: 'cash',
|
||||
selling: {
|
||||
type: 'rate',
|
||||
value: 0
|
||||
}
|
||||
},
|
||||
{
|
||||
payment_method: 'cheque',
|
||||
selling: {
|
||||
type: 'rate',
|
||||
value: 0
|
||||
}
|
||||
},
|
||||
{
|
||||
payment_method: 'ba',
|
||||
selling: {
|
||||
type: 'rate',
|
||||
value: 0
|
||||
}
|
||||
},
|
||||
{
|
||||
payment_method: 'wallet',
|
||||
selling: {
|
||||
type: 'rate',
|
||||
value: 0
|
||||
}
|
||||
},
|
||||
{
|
||||
payment_method: 'payment gateway',
|
||||
selling: {
|
||||
type: 'rate',
|
||||
value: 0
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
},
|
||||
mixins: [formHandler]
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,151 @@
|
||||
<template>
|
||||
<div class="row no-margin">
|
||||
<div class="col p-t-5 p-b-5 b-grey b-a">
|
||||
<div class="row text-center">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading font-orbitron text-danger-light">{{timer.days}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading all-caps fs-7 muted">Days</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto no-padding">
|
||||
<div class="font-heading p-b-5">:</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading font-orbitron text-danger-light">{{timer.hours}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading all-caps fs-7 muted">Hours</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto no-padding">
|
||||
<div class="font-heading p-b-5">:</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading font-orbitron text-danger-light">{{timer.minutes}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="font-heading all-caps fs-7 muted">Minutes</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto b-t b-b b-r b-grey pointer requestModal" data-type="paymentAttempt">
|
||||
<div class="row h-100 align-items-center">
|
||||
<div class="col p-l-10 p-r-10">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
|
||||
width="25" height="25"
|
||||
viewBox="0 0 172 172"
|
||||
style=" fill:#000000;"><defs><linearGradient x1="64.5" y1="40.25606" x2="64.5" y2="86.92719" gradientUnits="userSpaceOnUse" id="color-1_VhrilWh3UcXU_gr1"><stop offset="0" stop-color="#4ec9ff"></stop><stop offset="1" stop-color="#2bffe6"></stop></linearGradient><linearGradient x1="86" y1="10.80644" x2="86" y2="157.19456" gradientUnits="userSpaceOnUse" id="color-2_VhrilWh3UcXU_gr2"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="86" y1="10.80644" x2="86" y2="157.19456" gradientUnits="userSpaceOnUse" id="color-3_VhrilWh3UcXU_gr3"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient></defs><g fill="none" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><path d="M0,172v-172h172v172z" fill="none"></path><g><path d="M86,75.25v-32.25c-23.74944,0 -43,19.25056 -43,43h32.25c0,-5.93669 4.81331,-10.75 10.75,-10.75z" fill="url(#color-1_VhrilWh3UcXU_gr1)"></path><path d="M86,16.125c-38.53069,0 -69.875,31.34431 -69.875,69.875c0,38.53069 31.34431,69.875 69.875,69.875c38.53069,0 69.875,-31.34431 69.875,-69.875c0,-38.53069 -31.34431,-69.875 -69.875,-69.875zM86,150.5c-35.56369,0 -64.5,-28.93631 -64.5,-64.5c0,-35.56369 28.93631,-64.5 64.5,-64.5c35.56369,0 64.5,28.93631 64.5,64.5c0,35.56369 -28.93631,64.5 -64.5,64.5z" fill="url(#color-2_VhrilWh3UcXU_gr2)"></path><path d="M86,26.875c-32.60206,0 -59.125,26.52294 -59.125,59.125c0,32.60206 26.52294,59.125 59.125,59.125c32.60206,0 59.125,-26.52294 59.125,-59.125c0,-32.60206 -26.52294,-59.125 -59.125,-59.125zM139.61294,88.6875c-0.63694,12.78981 -5.74319,24.39444 -13.81375,33.31156l-5.59269,-5.59269l-3.80013,3.80013l5.59269,5.59269c-8.91712,8.07325 -20.51906,13.17681 -33.31156,13.81375v-7.92544h-5.375v7.92544c-12.78981,-0.63694 -24.39444,-5.74319 -33.31156,-13.81375l5.59269,-5.59269l-3.80013,-3.80013l-5.59269,5.59269c-8.07325,-8.91712 -13.17681,-20.51906 -13.81375,-33.31156h40.44687c1.24969,6.12481 6.67575,10.75 13.16606,10.75c7.40944,0 13.4375,-6.02806 13.4375,-13.4375c0,-6.48763 -4.62519,-11.91638 -10.75,-13.16606v-40.44687c12.78981,0.63694 24.39444,5.74319 33.31156,13.81375l-5.59269,5.59269l3.80013,3.80013l5.59269,-5.59269c8.07325,8.91713 13.17681,20.51906 13.81375,33.31156h-7.92544v5.375zM86,77.9375c4.44512,0 8.0625,3.61737 8.0625,8.0625c0,4.44512 -3.61738,8.0625 -8.0625,8.0625c-4.44512,0 -8.0625,-3.61738 -8.0625,-8.0625c0,-4.44512 3.61737,-8.0625 8.0625,-8.0625zM83.3125,32.38706v40.44687c-5.25675,1.07231 -9.40625,5.22181 -10.47856,10.47856h-40.44687c1.36794,-27.49044 23.435,-49.5575 50.92544,-50.92544z" fill="url(#color-3_VhrilWh3UcXU_gr3)"></path></g></g></svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="paymentAttempt">
|
||||
<payment-attempt-limit-form-component :data="{
|
||||
segment_id: this.segment_id,
|
||||
name: 'Payment Attempt Duration Limit',
|
||||
reference: this.reference,
|
||||
detail: {
|
||||
minutes: this.minutes
|
||||
}
|
||||
}" section="paymentAttemptSection" class="text-center"></payment-attempt-limit-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
segment_id: {
|
||||
required: true,
|
||||
type: Number,
|
||||
default: 1
|
||||
},
|
||||
data:{
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
reference: 'PAYMENT_ATTEMPT_DURATION_LIMIT',
|
||||
minutes: 0
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
pendingQueue () {
|
||||
return this.$store.getters.isInCompleteQueue(this.reference);
|
||||
},
|
||||
timer () {
|
||||
return {
|
||||
days: ('00'+Math.floor(this.minutes / 1440)).substr(('00'+Math.floor(this.minutes / 1440)).length-2),
|
||||
hours: ('00'+(Math.floor(this.minutes / 60) % 24)).substr(('00'+(Math.floor(this.minutes / 60) % 24)).length-2),
|
||||
minutes: ('00'+Math.floor(this.minutes % 60)).substr(('00'+Math.floor(this.minutes % 60)).length-2)
|
||||
};
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
pendingQueue(inComplete){
|
||||
if(inComplete){
|
||||
this.fetchTime();
|
||||
}
|
||||
},
|
||||
'data': function () {
|
||||
this.minutes = this.data
|
||||
}
|
||||
},
|
||||
created(){
|
||||
if(this.segment_id === 1){
|
||||
this.$store.dispatch('updateListQueue', {'name': this.reference});
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.data){
|
||||
this.minutes = this.data
|
||||
}
|
||||
|
||||
},
|
||||
methods: {
|
||||
fetchTime(){
|
||||
return this.submit(route('api.segment.constant.show', this.segment_id, this.reference), 'get', '', false, false)
|
||||
},
|
||||
successHandler(response){
|
||||
this.$store.dispatch('completeList', {'name': this.reference, 'data': response.payload.data});
|
||||
this.minutes = response.payload.data.detail.hasOwnProperty('minutes') ? response.payload.data.detail.minutes:0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.blink {
|
||||
animation: blink-animation 1s steps(5, start) infinite;
|
||||
-webkit-animation: blink-animation 1s steps(5, start) infinite;
|
||||
}
|
||||
@keyframes blink-animation {
|
||||
to {
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
@-webkit-keyframes blink-animation {
|
||||
to {
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,67 @@
|
||||
<template>
|
||||
<div class="col">
|
||||
<div class="row align-items-center m-b-30">
|
||||
<div class="col-3 p-l-0">
|
||||
<div class="font-heading fs-11 bold text-info">Full Name</div>
|
||||
</div>
|
||||
<div class="col m-r-50">
|
||||
<div class="font-heading fs-11 muted" v-text="$store.getters.getUserName"></div>
|
||||
</div>
|
||||
<div class="col-auto p-r-0">
|
||||
<div class="btn btn-xs btn-default bg-master-lighter btn-rounded p-r-20 p-l-15 requestModal" data-type="editFullName">
|
||||
<i class="fa fa-pencil m-r-10"></i>Edit
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row align-items-center m-b-30">
|
||||
<div class="col-3 p-l-0">
|
||||
<div class="font-heading fs-11 bold text-info">Password</div>
|
||||
</div>
|
||||
<div class="col m-r-50">
|
||||
<div class="font-heading fs-11 muted">********</div>
|
||||
</div>
|
||||
<div class="col-auto p-r-0">
|
||||
<div class="btn btn-xs btn-default bg-master-lighter btn-rounded p-r-20 p-l-15 requestModal" data-type="resetPassword">
|
||||
<i class="fa fa-lock m-r-10"></i>Request Password Reset
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row align-items-center">
|
||||
<div class="col-3 p-l-0">
|
||||
<div class="font-heading fs-11 bold text-info">Email Address</div>
|
||||
</div>
|
||||
<div class="col m-r-50">
|
||||
<div class="font-heading fs-11 muted" v-text="$store.getters.getUserEmail"></div>
|
||||
</div>
|
||||
<div class="col-auto p-r-0">
|
||||
<div class="btn btn-xs btn-default bg-master-lighter btn-rounded p-r-20 p-l-15 requestModal" data-type="editEmail">
|
||||
<i class="fa fa-envelope-open-o m-r-10"></i>Request Email Change
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="editFullName">
|
||||
<edit-user-profile-fullname-form-component :data="{name: $store.getters.getUserName}" :section="section"></edit-user-profile-fullname-form-component>
|
||||
</modal-component>
|
||||
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="resetPassword">
|
||||
<reset-user-password-form-component :data="{email: $store.getters.getUserEmail}" section="resetPassword"></reset-user-password-form-component>
|
||||
</modal-component>
|
||||
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="editEmail">
|
||||
<edit-email-form-component :data="{email: $store.getters.getUserEmail}" section="editEmail"></edit-email-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
section: {
|
||||
default: "editFullNameSection",
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,128 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<loading-component style="height: 50px; top: 0;" key="1" color="success" v-show="$store.getters.isLoading(section)"></loading-component>
|
||||
<div class="row" v-show="!$store.getters.isLoading(section)">
|
||||
<div class="col">
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<h6 class="all-caps m-b-5 bold no-margin">{{this.data?"Update":"Create"}} Announcement</h6>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-5 animate__animated animate__fadeInUpBig animate__fast" v-if="error">
|
||||
<div class="col">
|
||||
<small class="bold fs-10 text-danger">{{error}}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.parameters.title">
|
||||
<label>Title</label>
|
||||
<input type="text" class="form-control" v-model="parameters.title">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.parameters.description">
|
||||
<label>Message</label>
|
||||
<textarea class="form-control h-75" v-model="parameters.description" rows="20"></textarea>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row m-b-20">
|
||||
<div class="col-6">
|
||||
<validation-wrapper-component :validator="$v.parameters.starting_on">
|
||||
<label>Start Date</label>
|
||||
<input type="date" v-model="parameters.starting_on">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<validation-wrapper-component :validator="$v.parameters.ending_on">
|
||||
<label>End Date</label>
|
||||
<input type="date" v-model="parameters.ending_on">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div class="btn btn-sm btn-default bg-master-lightest btn-block b-rad-none" :data-dismiss="closable ? 'modal' : ''" @click="$emit('close')">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-sm btn-success btn-block b-rad-none" @click="submitForm()">{{this.data?"Update":"Create"}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
import { required, requiredIf } from "vuelidate/lib/validators";
|
||||
export default {
|
||||
props : {
|
||||
closable: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
country_id: {
|
||||
type: Number,
|
||||
default: 1
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
parameters: {
|
||||
starting_on:'',
|
||||
ending_on:'',
|
||||
// segment_id: '',
|
||||
title: '',
|
||||
description: '',
|
||||
}
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
parameters: {
|
||||
title: {
|
||||
required
|
||||
},
|
||||
description: {
|
||||
required
|
||||
},
|
||||
// segment_id: {
|
||||
// required
|
||||
// },
|
||||
starting_on:{
|
||||
required
|
||||
},
|
||||
ending_on:{
|
||||
required
|
||||
},
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
|
||||
},
|
||||
created(){
|
||||
console.log("lado form");
|
||||
},
|
||||
methods: {
|
||||
submitForm(){
|
||||
//this.submit(route('api.announcement.create'), 'post', this.section, true, false);
|
||||
this.submit((this.data ? this.route('api.announcement.update', this.data.id) : this.route('api.announcement.create')), (this.data ? 'put' : 'post'), this.section, true, false)
|
||||
},
|
||||
// successHandler(response){
|
||||
// this.closeModal();
|
||||
// //this.formHandler();
|
||||
// this.resetForm();
|
||||
// },
|
||||
// errorHandler(error){
|
||||
// this.formHandler(error.message);
|
||||
// }
|
||||
},
|
||||
mixins: [ModalFormHandler],
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,33 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<loading-component style="height: 300px; top: 0;" key="1" color="success" v-show="isLoading" ></loading-component>
|
||||
<div class="row justify-content-center" v-show="!isLoading">
|
||||
<div class="col">
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<h3 class="all-caps">Are you Sure?</h3>
|
||||
<div class="fs-11">Are you sure you want to delete announcement with title <b>{{item.title}}</b> ?</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div class="btn btn-sm btn-success btn-block b-rad-none" data-dismiss="modal">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-sm btn-danger btn-block b-rad-none" @click="submit(route('api.announcement.delete', item.id), 'delete', section, true, true)">Delete</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
export default {
|
||||
mixins: [componentHandler, ModalFormHandler]
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,58 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
<h5 class="all-caps m-b-5 bold no-margin">Change Email Address</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-5 animate__animated animate__fadeInUpBig animate__fast" v-if="error">
|
||||
<div class="col">
|
||||
<small class="bold fs-10 text-danger">{{error}}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.parameters.email">
|
||||
<label>New Email Address</label>
|
||||
<input type="text" class="form-control" v-model="parameters.email">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div class="btn btn-sm btn-default bg-master-lightest btn-block b-rad-none" data-dismiss="modal">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-sm btn-success btn-block b-rad-none" @click="submit(route('api.company.team.create'), 'post', section, true, false)">Update</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { required, email } from "vuelidate/lib/validators";
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
error: '',
|
||||
parameters: {
|
||||
email: this.data.email,
|
||||
}
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
parameters: {
|
||||
email: { required, email }
|
||||
}
|
||||
},
|
||||
mixins: [ModalFormHandler]
|
||||
|
||||
}
|
||||
</script>
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
<h3 class="all-caps m-b-5 bold no-margin">Edit Full Name</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.parameters.name">
|
||||
<label>Full Name</label>
|
||||
<input type="text" class="form-control" v-model="parameters.name">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-5 animate__animated animate__fadeInUpBig animate__fast" v-if="error">
|
||||
<div class="col">
|
||||
<small class="bold fs-10 text-danger">{{error}}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div class="btn btn-sm btn-default bg-master-lightest btn-block b-rad-none" data-dismiss="modal">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-sm btn-success btn-block b-rad-none" @click="submit(route('api.account.user.update', $store.getters.getUserId), 'put', section, true, true)">Update</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import updateProfileFormValidation from '../../../general/mixins/accounts/validation/updateProfileFormValidation';
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
error: '',
|
||||
parameters: {
|
||||
name: this.data.name,
|
||||
}
|
||||
}
|
||||
},
|
||||
mixins: [updateProfileFormValidation]
|
||||
|
||||
}
|
||||
</script>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user