mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
transfer booking owner
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Bookings\ControllersLogic;
|
||||
|
||||
use App\Http\Resources\BookingResource;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Bookings\Services\FetchesBooking;
|
||||
use App\Classes\Modules\Bookings\Standards\Rules\CanUpdateBooking;
|
||||
use App\Classes\Modules\Bookings\Services\UpdatesBookingOwner;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Bookings\Standards\Rules\CanFetchBooking;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Models\Company;
|
||||
|
||||
class UpdateBookingOwnerLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Update Booking Owner',
|
||||
'message' => "You have successfully updated booking's owner"
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateBooking */
|
||||
private $canUpdateBooking;
|
||||
|
||||
/** @var UpdatesBookingOwner */
|
||||
private $updatesBookingOwner;
|
||||
|
||||
/** @var FetchesBooking */
|
||||
private $fetchesBooking;
|
||||
|
||||
/** @var CanFetchBooking */
|
||||
private $canFetchBooking;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/**
|
||||
* UpdateBookingLogic constructor.
|
||||
* @param CanUpdateBooking $canUpdateBooking
|
||||
* @param UpdatesBookingOwner $updatesBookingOwner
|
||||
* @param CanFetchBooking $canFetchBooking
|
||||
* @param FetchesBooking $fetchesBooking
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateBooking $canUpdateBooking,
|
||||
UpdatesBookingOwner $updatesBookingOwner,
|
||||
CanFetchBooking $canFetchBooking,
|
||||
FetchesBooking $fetchesBooking,
|
||||
FetchesCompany $fetchesCompany
|
||||
) {
|
||||
$this->canUpdateBooking = $canUpdateBooking;
|
||||
$this->updatesBookingOwner = $updatesBookingOwner;
|
||||
$this->canFetchBooking = $canFetchBooking;
|
||||
$this->fetchesBooking = $fetchesBooking;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$this->canFetchBooking->passes();
|
||||
|
||||
$booking = $this->fetchesBooking->execute([
|
||||
'id' => $request->route('id'),
|
||||
]);
|
||||
|
||||
$newCompanyId = Company::where('reference', $request->input('newMarking'))->first()->id;
|
||||
|
||||
$this->updatesBookingOwner->execute($booking, $newCompanyId);
|
||||
|
||||
return $this->resourceResponse(new BookingResource($booking));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Bookings\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Booking;
|
||||
|
||||
class UpdatesBookingOwner extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Booking $model
|
||||
* @param int $id
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Booking $model, int $id)
|
||||
{
|
||||
$model->company_id = $id;
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bookings;
|
||||
|
||||
use App\Classes\Modules\Bookings\ControllersLogic\UpdateBookingOwnerLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateBookingOwnerController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param RegenerateInvoiceBookingLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateBookingOwnerLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<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 Booking Owner</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.newMarking">
|
||||
<label class="text-left">Customer Marking</label>
|
||||
<input type="text" class="form-control" v-model="parameters.newMarking">
|
||||
</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="submitForm()">Submit</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { required } from "vuelidate/lib/validators";
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
error: '',
|
||||
parameters: {
|
||||
newMarking: '',
|
||||
},
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
parameters: {
|
||||
newMarking: { },
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
submitForm() {
|
||||
this.submit(route('api.booking.owner.update', this.data.id), 'put', this.section, true, true);
|
||||
}
|
||||
},
|
||||
mixins: [ModalFormHandler]
|
||||
}
|
||||
</script>
|
||||
@@ -426,6 +426,14 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-5" v-if="$store.getters.isAdmin">
|
||||
<div class="col">
|
||||
<div class="btn btn-xs all-caps b-rad-none btn-warning pointer requestModal" data-type="changeBookingOwner">Change Booking Owner</div>
|
||||
<modal-component type="changeBookingOwner">
|
||||
<change-booking-owner-form-component :data="booking" :section="section" class="text-center"></change-booking-owner-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-sm-12 col-md-3">
|
||||
<wallet-component class="m-b-20" :data="booking.company"></wallet-component>
|
||||
|
||||
@@ -12,6 +12,8 @@ Route::group(['prefix' => 'booking', 'as' => 'booking.', 'namespace' => 'Booking
|
||||
Route::delete('/delete/{id}', 'DeleteBookingController@delete')->name('delete');
|
||||
Route::post('/regenerate/invoice/{id}', 'RegenerateInvoiceBookingController@regenerate')->name('regenerate.invoice');
|
||||
|
||||
Route::put('/owner/update/{id}', 'UpdateBookingOwnerController@update')->name('owner.update');
|
||||
|
||||
Route::group(['prefix' => '{id}/payment', 'as' => 'payment.'], function () {
|
||||
Route::post('quotation', 'FetchBookingPaymentQuotationController@fetch')->name('quotation');
|
||||
Route::post('create', 'CreateBookingPaymentController@create')->name('create');
|
||||
|
||||
Reference in New Issue
Block a user