diff --git a/app/Classes/Modules/Bookings/ControllersLogic/UploadSalesAgreementLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/UploadSalesAgreementLogic.php new file mode 100644 index 00000000..aabe9210 --- /dev/null +++ b/app/Classes/Modules/Bookings/ControllersLogic/UploadSalesAgreementLogic.php @@ -0,0 +1,71 @@ + 'Sales Agreement Document', + 'message' => 'You have successfully uploaded sales agreement document' + ]; + } + + /** @var FetchesCompany */ + private $fetchesCompany; + + /** @var CreatesDocument */ + private $createsDocument; + + /** @var CreatesFiles */ + private $createsFile; + + /** + * CreatePaymentVerificationDocumentLogic constructor. + * @param FetchesCompany $fetchesCompany + * @param CreatesDocument $createsDocument + * @param CreatesFiles $createsFile + */ + public function __construct(FetchesCompany $fetchesCompany, CreatesDocument $createsDocument, CreatesFiles $createsFile) + { + $this->fetchesCompany = $fetchesCompany; + $this->createsDocument = $createsDocument; + $this->createsFile = $createsFile; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function logic(Request $request) : JsonResponse + { + $company = $this->fetchesCompany->execute(['id' => $request->route('company_id')]); + + $object = new DocumentObject(DocumentType::SALES_AGREEMENT, $request->input('files'), '', ApprovalStatus::PENDING_VERIFICATION, 'sales_agreement'); + + /** @var Document $document */ + $document = $this->createsDocument->execute($company, $object); + + $this->createsFile->execute($document, $object); + + return $this->response([]); + } + +} \ No newline at end of file diff --git a/app/Classes/ValueObjects/Constants/DocumentType.php b/app/Classes/ValueObjects/Constants/DocumentType.php index 04edf25c..cad88ffa 100644 --- a/app/Classes/ValueObjects/Constants/DocumentType.php +++ b/app/Classes/ValueObjects/Constants/DocumentType.php @@ -22,4 +22,6 @@ final class DocumentType { public const DELIVER_ORDER = 'DELIVER_ORDER'; public const INVOICE = 'INVOICE'; public const SUPPLIER_DELIVER_ORDER = 'SUPPLIER_DELIVER_ORDER'; + + public const SALES_AGREEMENT = 'SALES_AGREEMENT'; } diff --git a/app/Http/Controllers/Bookings/UploadSalesAgreementController.php b/app/Http/Controllers/Bookings/UploadSalesAgreementController.php new file mode 100644 index 00000000..7ba370c0 --- /dev/null +++ b/app/Http/Controllers/Bookings/UploadSalesAgreementController.php @@ -0,0 +1,20 @@ +execute($request); + } +} diff --git a/routes/booking.php b/routes/booking.php index 87c1af0f..2ae135db 100644 --- a/routes/booking.php +++ b/routes/booking.php @@ -34,4 +34,6 @@ Route::group(['prefix' => 'booking', 'as' => 'booking.', 'namespace' => 'Booking Route::post('{id}/trust_seller', 'TrustSellerController@trust')->name('trust_seller'); + Route::post('{id}/upload/{company_id}', 'UploadSalesAgreementController@upload')->name('upload.sales_agreement'); + }); \ No newline at end of file