diff --git a/app/Classes/Modules/Bookings/ControllersLogic/TrustSellerLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/TrustSellerLogic.php new file mode 100644 index 00000000..c94b5f8d --- /dev/null +++ b/app/Classes/Modules/Bookings/ControllersLogic/TrustSellerLogic.php @@ -0,0 +1,57 @@ + 'Trust the seller', + 'message' => 'You have successfully approved the seller' + ]; + } + + /** @var FetchesBooking */ + private $fetchesBooking; + + /** @var UpdatesBookingTrusted */ + private $updatesBookingTrusted; + + /** + * TrustedSellerLogic constructor. + * @param FetchesBooking $fetchesBooking + * @param UpdatesBookingTrusted $updatesBookingTrusted + */ + public function __construct(FetchesBooking $fetchesBooking, UpdatesBookingTrusted $updatesBookingTrusted) + { + $this->fetchesBooking = $fetchesBooking; + $this->updatesBookingTrusted = $updatesBookingTrusted; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function logic(Request $request) : JsonResponse + { + $booking = $this->fetchesBooking->execute(['id' => $request->route('id')]); + + $this->updatesBookingTrusted->execute($booking, BookingTrust::TRUSTED); + + return $this->response([]); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Bookings/Services/UpdatesBookingTrusted.php b/app/Classes/Modules/Bookings/Services/UpdatesBookingTrusted.php new file mode 100644 index 00000000..5fc9507f --- /dev/null +++ b/app/Classes/Modules/Bookings/Services/UpdatesBookingTrusted.php @@ -0,0 +1,21 @@ +trusted = $bool; + return $this->handler($model); + } +} \ No newline at end of file diff --git a/app/Classes/ValueObjects/Constants/BookingTrust.php b/app/Classes/ValueObjects/Constants/BookingTrust.php new file mode 100644 index 00000000..aafedb5b --- /dev/null +++ b/app/Classes/ValueObjects/Constants/BookingTrust.php @@ -0,0 +1,10 @@ +fetchesServiceType = $fetchesServiceType; + parent::__construct(); + } + + /** + * Execute the console command. + * + * @return int + */ + public function handle() + { + $test = $this->fetchesServiceType->execute(['id' => 5]); + + dd($test->name); + } +} diff --git a/app/Http/Controllers/Bookings/TrustSellerController.php b/app/Http/Controllers/Bookings/TrustSellerController.php new file mode 100644 index 00000000..d16151b2 --- /dev/null +++ b/app/Http/Controllers/Bookings/TrustSellerController.php @@ -0,0 +1,20 @@ +execute($request); + } +} diff --git a/database/migrations/2022_05_16_142320_add_column_to_bookings.php b/database/migrations/2022_05_16_142320_add_column_to_bookings.php new file mode 100644 index 00000000..374e5d68 --- /dev/null +++ b/database/migrations/2022_05_16_142320_add_column_to_bookings.php @@ -0,0 +1,33 @@ +integer('trusted')->default(BookingTrust::UNTRUSTED)->nullable()->after('status'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('bookings', function (Blueprint $table) { + $table->dropColumn('trusted'); + }); + } +} diff --git a/routes/booking.php b/routes/booking.php index d83bb4af..87c1af0f 100644 --- a/routes/booking.php +++ b/routes/booking.php @@ -32,4 +32,6 @@ Route::group(['prefix' => 'booking', 'as' => 'booking.', 'namespace' => 'Booking Route::post('{id}/proforma/create', 'CreateProformaInvoiceTransaction@create')->name('proforma.create'); + Route::post('{id}/trust_seller', 'TrustSellerController@trust')->name('trust_seller'); + }); \ No newline at end of file