mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-23 22:44:19 +00:00
WIP - Order steps & remaining APIs
This commit is contained in:
@@ -32,6 +32,12 @@ class CreateOrderProcessor
|
||||
|
||||
public function execute(Request $request){
|
||||
|
||||
//TODO: Generate internal reference number
|
||||
//faker->numberBetween(1000000, 9999999),
|
||||
|
||||
//TODO: Call Unity to create contract and get contract reference no (and all the obligations)
|
||||
//$contract_reference_no = 99;
|
||||
|
||||
$order_object = new OrderObject($request->get('company_module_id'), $request->get('reference'), '', OrderType::SHARED_CONTAINER, OrderStatus::PROCESSING, OrderSteps::PROCESSING);
|
||||
|
||||
$this->canCreateOrder->passes($order_object);
|
||||
|
||||
@@ -5,10 +5,9 @@ namespace App\Classes\Modules\Remarks\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Remarks\Services\CreatesRemark;
|
||||
use App\Classes\Modules\Remarks\Services\FetchesDistrict;
|
||||
use App\Classes\Modules\Remarks\Standards\Rules\CanCreateRemark;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
||||
use App\Http\Resources\RemarkResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -30,28 +29,22 @@ class CreateRemarkLogic extends AbstractControllerLogic
|
||||
/** @var CanCreateRemark */
|
||||
private $canCreateRemark;
|
||||
|
||||
/** @var FetchesDistrict */
|
||||
private $fetchesDistrict;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var CreatesRemark */
|
||||
private $createsRemark;
|
||||
|
||||
/** @var FetchesUser */
|
||||
private $fetchesUser;
|
||||
|
||||
/**
|
||||
* CreateRemarkLogic constructor.
|
||||
* @param CanCreateRemark $canCreateRemark
|
||||
* @param FetchesDistrict $fetchesDistrict
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param CreatesRemark $createsRemark
|
||||
*/
|
||||
public function __construct(CanCreateRemark $canCreateRemark, FetchesDistrict $fetchesDistrict, FetchesCompany $fetchesCompany, CreatesRemark $createsRemark)
|
||||
public function __construct(CanCreateRemark $canCreateRemark, CreatesRemark $createsRemark, FetchesUser $fetchesUser)
|
||||
{
|
||||
$this->canCreateRemark = $canCreateRemark;
|
||||
$this->fetchesDistrict = $fetchesDistrict;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->createsRemark = $createsRemark;
|
||||
$this->fetchesUser = $fetchesUser;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,13 +57,11 @@ class CreateRemarkLogic extends AbstractControllerLogic
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||
|
||||
$object = new RemarkObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code'));
|
||||
$object = new RemarkObject($request->input('comment'), $request->input('commenter_id'));
|
||||
|
||||
$this->canCreateRemark->passes($object);
|
||||
|
||||
$query = $this->createsRemark->execute($this->fetchesCompany->execute(['id' => $request->input('company_id')]), $object);
|
||||
$query = $this->createsRemark->execute($this->fetches->execute(['id' => $request->input('commenter_id')]), $object);
|
||||
|
||||
return $this->resourceResponse(new RemarkResource($query));
|
||||
|
||||
|
||||
@@ -62,24 +62,16 @@ class UpdateRemarkLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||
$object = new RemarkObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code'));
|
||||
//$object = new RemarkObject($request->input('company_id'), $request->input('street_one'), $request->input('street_two'), $request->input('city'), $request->input('state'), $request->input('post_code'), $request->input('country'), $request->input('default'), $request->input('billing'));
|
||||
$object = new RemarkObject($request->input('comment'), $request->input('commenter_id'));
|
||||
|
||||
$this->canUpdateRemark->passes($object);
|
||||
$this->canUpdateRemark->passes($object);
|
||||
|
||||
$query = $this->fetchesRemark->execute(['id' => $request->route('id')]);
|
||||
$query = $this->fetchesRemark->execute(['id' => $request->route('id')]);
|
||||
|
||||
$query = $this->updatesRemark->execute($query, $object);
|
||||
$query = $this->updatesRemark->execute($query, $object);
|
||||
|
||||
return $this->resourceResponse(new RemarkResource($query));
|
||||
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
return $this->resourceResponse(new RemarkResource($query));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,90 +7,32 @@ use App\Classes\General\Interfaces\DataTransferObject;
|
||||
class RemarkObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $streetOne;
|
||||
/** @var int */
|
||||
private $commenterID;
|
||||
|
||||
/** @var string|null */
|
||||
private $streetTwo;
|
||||
/** @var string*/
|
||||
private $comment;;
|
||||
|
||||
/** @var int */
|
||||
private $countryId;
|
||||
|
||||
/** @var int */
|
||||
private $stateId;
|
||||
|
||||
/** @var int */
|
||||
private $districtId;
|
||||
|
||||
/** @var int */
|
||||
private $postCode;
|
||||
public function __construct(int $commenterID, string $comment)
|
||||
{
|
||||
$this->commenterID = $commenterID;
|
||||
$this->comment = $comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* RemarkObject constructor.
|
||||
* @param string $streetOne
|
||||
* @param null|string $streetTwo
|
||||
* @param int $countryId
|
||||
* @param int $stateId
|
||||
* @param int $districtId
|
||||
* @param int $postCode
|
||||
* @return int
|
||||
*/
|
||||
public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, int $postCode)
|
||||
public function getCommenterId(): string
|
||||
{
|
||||
$this->streetOne = $streetOne;
|
||||
$this->streetTwo = $streetTwo;
|
||||
$this->countryId = $countryId;
|
||||
$this->stateId = $stateId;
|
||||
$this->districtId = $districtId;
|
||||
$this->postCode = $postCode;
|
||||
return $this->commenterID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStreetOne(): string
|
||||
public function getComment(): ?string
|
||||
{
|
||||
return $this->streetOne;
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getStreetTwo(): ?string
|
||||
{
|
||||
return $this->streetTwo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCountryId(): int
|
||||
{
|
||||
return $this->countryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStateId(): int
|
||||
{
|
||||
return $this->stateId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDistrictId(): int
|
||||
{
|
||||
return $this->districtId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPostCode(): int
|
||||
{
|
||||
return $this->postCode;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Models\Remark;
|
||||
use App\Models\Company;
|
||||
use App\Models\User;
|
||||
|
||||
class CreatesRemark extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
@@ -17,16 +17,13 @@ class CreatesRemark extends AbstractUpdateRelationshipRecord
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Company $company, RemarkObject $object) {
|
||||
public function execute(User $user, RemarkObject $object) {
|
||||
$model = new Remark();
|
||||
$model->street_one = $object->getStreetOne();
|
||||
$model->street_two = $object->getStreetTwo();
|
||||
$model->country_id = $object->getCountryId();
|
||||
$model->state_id = $object->getStateId();
|
||||
$model->district_id = $object->getDistrictId();
|
||||
$model->postcode = $object->getPostCode();
|
||||
|
||||
return $this->handler($company->Remarks(), $model);
|
||||
$model->commenter_id = $object->getCommenterId();
|
||||
$model->comment = $object->getComment();
|
||||
|
||||
return $this->handler($user->remarks(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,8 @@ class UpdatesRemark extends AbstractUpdateRecord
|
||||
*/
|
||||
public function execute(Remark $model, RemarkObject $object) {
|
||||
|
||||
//$model->company_id = $object->getCompanyId();
|
||||
$model->street_one = $object->getStreetOne();
|
||||
$model->street_two = $object->getStreetTwo();
|
||||
$model->district_id = $object->getDistrictId();
|
||||
$model->state_id = $object->getStateId();
|
||||
$model->postcode = $object->getPostCode();
|
||||
$model->country_id = $object->getCountryId();
|
||||
//$model->default = $object->getDefault();
|
||||
//$model->billing = $object->getBilling();
|
||||
$model->commenter_id = $object->getCommenterId();
|
||||
$model->comment = $object->getComment();
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
|
||||
@@ -16,9 +16,8 @@ class RemarkValidation extends AbstractValidation
|
||||
*/
|
||||
protected function data($object): array {
|
||||
return [
|
||||
'street_one' => $object->getStreetOne(),
|
||||
'street_two' => $object->getStreetTwo(),
|
||||
'district_id' => $object->getDistrictId()
|
||||
'commenter_id' => $object->getCommenterId(),
|
||||
'comment' => $object->getComment(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -27,8 +26,8 @@ class RemarkValidation extends AbstractValidation
|
||||
*/
|
||||
protected function rules(): array {
|
||||
return [
|
||||
'street_one' => 'required',
|
||||
'district_id' => 'required',
|
||||
'commenter_id' => 'required',
|
||||
'comment' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
|
||||
namespace App\Classes\Modules\Schedules\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Schedules\Services\FetchesDistrict;
|
||||
use App\Classes\Modules\Schedules\Standards\Rules\CanCreateSchedule;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Transports\Services\FetchesTransport;
|
||||
use App\Http\Resources\ScheduleResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -16,7 +14,6 @@ use Illuminate\Http\Request;
|
||||
|
||||
class CreateScheduleLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -30,11 +27,8 @@ class CreateScheduleLogic extends AbstractControllerLogic
|
||||
/** @var CanCreateSchedule */
|
||||
private $canCreateSchedule;
|
||||
|
||||
/** @var FetchesDistrict */
|
||||
private $fetchesDistrict;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
/** @var FetchesTransport */
|
||||
private $fetchesTransport;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
@@ -42,15 +36,13 @@ class CreateScheduleLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* CreateScheduleLogic constructor.
|
||||
* @param CanCreateSchedule $canCreateSchedule
|
||||
* @param FetchesDistrict $fetchesDistrict
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param FetchesTransport $fetchesTransport
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
*/
|
||||
public function __construct(CanCreateSchedule $canCreateSchedule, FetchesDistrict $fetchesDistrict, FetchesCompany $fetchesCompany, CreatesSchedule $createsSchedule)
|
||||
public function __construct(CanCreateSchedule $canCreateSchedule, FetchesTransport $fetchesTransport, CreatesSchedule $createsSchedule)
|
||||
{
|
||||
$this->canCreateSchedule = $canCreateSchedule;
|
||||
$this->fetchesDistrict = $fetchesDistrict;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesTransport = $fetchesTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
}
|
||||
|
||||
@@ -63,17 +55,13 @@ class CreateScheduleLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||
|
||||
$object = new ScheduleObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code'));
|
||||
$object = new ScheduleObject($request->input('etd'), $request->input('eta'), $request->input('transport_id'));
|
||||
|
||||
$this->canCreateSchedule->passes($object);
|
||||
|
||||
$query = $this->createsSchedule->execute($this->fetchesCompany->execute(['id' => $request->input('company_id')]), $object);
|
||||
$query = $this->createsSchedule->execute($this->fetchesTransport->execute(['id' => $request->input('transport_id')]), $object);
|
||||
|
||||
return $this->resourceResponse(new ScheduleResource($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ class DeleteScheduleLogic extends AbstractControllerLogic
|
||||
$this->fetchesSchedule = $fetchesSchedule;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
@@ -54,20 +53,13 @@ class DeleteScheduleLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
$this->canDeleteSchedule->passes();
|
||||
|
||||
$this->canDeleteSchedule->passes();
|
||||
$query = $this->fetchesSchedule->execute(['id' => $request->route('id')]);
|
||||
|
||||
$query = $this->fetchesSchedule->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->deletesSchedule->execute($query);
|
||||
|
||||
return $this->response([]);
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
$this->deletesSchedule->execute($query);
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,18 +49,11 @@ class FetchScheduleLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
$this->canFetchSchedule->passes();
|
||||
|
||||
$this->canFetchSchedule->passes();
|
||||
|
||||
$query = $this->fetchesSchedule->execute(['id' => $request->route('id')]);
|
||||
|
||||
return $this->resourceResponse(new ScheduleResource($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
$query = $this->fetchesSchedule->execute(['id' => $request->route('id')]);
|
||||
|
||||
return $this->resourceResponse(new ScheduleResource($query));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,18 +49,11 @@ class ListSchedulesLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
$this->canListSchedules->passes();
|
||||
|
||||
$this->canListSchedules->passes();
|
||||
|
||||
$query = $this->listsSchedules->execute($this->listsSchedules->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(ScheduleResource::collection($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
$query = $this->listsSchedules->execute($this->listsSchedules->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(ScheduleResource::collection($query));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -62,25 +62,15 @@ class UpdateScheduleLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
$object = new ScheduleObject($request->input('etd'), $request->input('eta'));
|
||||
|
||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||
$object = new ScheduleObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code'));
|
||||
//$object = new ScheduleObject($request->input('company_id'), $request->input('street_one'), $request->input('street_two'), $request->input('city'), $request->input('state'), $request->input('post_code'), $request->input('country'), $request->input('default'), $request->input('billing'));
|
||||
$this->canUpdateSchedule->passes($object);
|
||||
|
||||
$this->canUpdateSchedule->passes($object);
|
||||
$query = $this->fetchesSchedule->execute(['id' => $request->route('id')]);
|
||||
|
||||
$query = $this->fetchesSchedule->execute(['id' => $request->route('id')]);
|
||||
|
||||
$query = $this->updatesSchedule->execute($query, $object);
|
||||
|
||||
return $this->resourceResponse(new ScheduleResource($query));
|
||||
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
$query = $this->updatesSchedule->execute($query, $object);
|
||||
|
||||
return $this->resourceResponse(new ScheduleResource($query));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,94 +3,55 @@
|
||||
namespace App\Classes\Modules\Schedules\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ScheduleObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $streetOne;
|
||||
/** @var Carbonn date */
|
||||
private $etd;
|
||||
|
||||
/** @var string|null */
|
||||
private $streetTwo;
|
||||
/** @var Carbon date */
|
||||
private $eta;
|
||||
|
||||
/** @var int */
|
||||
private $countryId;
|
||||
|
||||
/** @var int */
|
||||
private $stateId;
|
||||
|
||||
/** @var int */
|
||||
private $districtId;
|
||||
|
||||
/** @var int */
|
||||
private $postCode;
|
||||
private $transport_id;
|
||||
|
||||
/**
|
||||
* ScheduleObject constructor.
|
||||
* @param string $streetOne
|
||||
* @param null|string $streetTwo
|
||||
* @param int $countryId
|
||||
* @param int $stateId
|
||||
* @param int $districtId
|
||||
* @param int $postCode
|
||||
* ScheduleObject constructor
|
||||
* @param int $etd
|
||||
* @param int $eta
|
||||
* @param int $transport_id
|
||||
*/
|
||||
public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, int $postCode)
|
||||
public function __construct(string $etd, string $eta, int $transport_id)
|
||||
{
|
||||
$this->streetOne = $streetOne;
|
||||
$this->streetTwo = $streetTwo;
|
||||
$this->countryId = $countryId;
|
||||
$this->stateId = $stateId;
|
||||
$this->districtId = $districtId;
|
||||
$this->postCode = $postCode;
|
||||
$this->etd = $etd;
|
||||
$this->eta = $eta;
|
||||
$this->transport_id = $transport_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStreetOne(): string
|
||||
public function getETD(): Carbon
|
||||
{
|
||||
return $this->streetOne;
|
||||
return $this->completed_date ? Carbon::parse($this->etd);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
* @return string
|
||||
*/
|
||||
public function getStreetTwo(): ?string
|
||||
public function getETA(): Carbon
|
||||
{
|
||||
return $this->streetTwo;
|
||||
return $this->completed_date ? Carbon::parse($this->eta);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCountryId(): int
|
||||
public function getTransportId(): int
|
||||
{
|
||||
return $this->countryId;
|
||||
return $this->transport_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStateId(): int
|
||||
{
|
||||
return $this->stateId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDistrictId(): int
|
||||
{
|
||||
return $this->districtId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPostCode(): int
|
||||
{
|
||||
return $this->postCode;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,27 +6,24 @@ use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Models\Schedule;
|
||||
use App\Models\Company;
|
||||
use App\Models\TransportArrangement;
|
||||
|
||||
class CreatesSchedule extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Company $company
|
||||
* @param TransportArrangement $transport
|
||||
* @param ScheduleObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Company $company, ScheduleObject $object) {
|
||||
public function execute(TransportArrangement $transport, ScheduleObject $object) {
|
||||
$model = new Schedule();
|
||||
$model->street_one = $object->getStreetOne();
|
||||
$model->street_two = $object->getStreetTwo();
|
||||
$model->country_id = $object->getCountryId();
|
||||
$model->state_id = $object->getStateId();
|
||||
$model->district_id = $object->getDistrictId();
|
||||
$model->postcode = $object->getPostCode();
|
||||
$model->etd = $object->getETD();
|
||||
$model->eta = $object->getETA();
|
||||
$model->transport_id = $object->getTransportId();
|
||||
|
||||
return $this->handler($company->Schedules(), $model);
|
||||
return $this->handler($transport->schedules(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,8 @@ class UpdatesSchedule extends AbstractUpdateRecord
|
||||
*/
|
||||
public function execute(Schedule $model, ScheduleObject $object) {
|
||||
|
||||
//$model->company_id = $object->getCompanyId();
|
||||
$model->street_one = $object->getStreetOne();
|
||||
$model->street_two = $object->getStreetTwo();
|
||||
$model->district_id = $object->getDistrictId();
|
||||
$model->state_id = $object->getStateId();
|
||||
$model->postcode = $object->getPostCode();
|
||||
$model->country_id = $object->getCountryId();
|
||||
//$model->default = $object->getDefault();
|
||||
//$model->billing = $object->getBilling();
|
||||
$model->etd = $object->getETD();
|
||||
$model->eta = $object->getETA();
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
|
||||
@@ -16,9 +16,8 @@ class ScheduleValidation extends AbstractValidation
|
||||
*/
|
||||
protected function data($object): array {
|
||||
return [
|
||||
'street_one' => $object->getStreetOne(),
|
||||
'street_two' => $object->getStreetTwo(),
|
||||
'district_id' => $object->getDistrictId()
|
||||
'etd' => $object->getETD(),
|
||||
'eta' => $object->getETA(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -27,8 +26,9 @@ class ScheduleValidation extends AbstractValidation
|
||||
*/
|
||||
protected function rules(): array {
|
||||
return [
|
||||
'street_one' => 'required',
|
||||
'district_id' => 'required',
|
||||
'transport_id' => 'required',
|
||||
'etd' => 'required',
|
||||
'eta' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PackageResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'order_id' => $this->order_id,
|
||||
'claimant_id' => $this->claimant_id,
|
||||
'type' => $this->type,
|
||||
'description' => $this->description,
|
||||
'width' => $this->width,
|
||||
'height' => $this->height,
|
||||
'length' => $this->length,
|
||||
'weight' => $this->weight,
|
||||
'quantity' => $this->quantity,
|
||||
'status' => $this->status,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PackingListResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'reference' => $this->reference,
|
||||
'status' => $this->status,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class RemarkResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'commenter_id' => $this->commenter_id,
|
||||
'comment' => $this->comment,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ScheduleResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'etd' => $this->etd,
|
||||
'eta' => $this->eta,
|
||||
'status' => $this->status,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class TransportResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'type' => $this->type,
|
||||
'courier' => $this->courier,
|
||||
'tracking_number' => $this->tracking_number,
|
||||
'dispatch_date' => $this->dispatch_date,
|
||||
'drop_date' => $this->drop_date,
|
||||
'status' => $this->status,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -73,4 +73,12 @@ class User extends AbstractModel implements
|
||||
{
|
||||
return $this->morphMany(Contact::class, 'owner');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function remarks(): morphMany
|
||||
{
|
||||
return $this->morphMany(Remark::class, 'owner');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user