mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
add function to add contact person
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
||||
use App\Http\Resources\ContactResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Http\Resources\CompanyResource;
|
||||
|
||||
class CreateCompanyContactNumberLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Company Contact Number',
|
||||
'message' => 'You have successfully created the Company Contact Number'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var CreatesContact */
|
||||
private $createsContact;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/**
|
||||
* UpdateCompanyControllersLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param CreatesContact $createsContact
|
||||
* @param CreateContactProcessor $createContactProcessor
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, CreatesContact $createsContact, CreateContactProcessor $createContactProcessor)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->createsContact = $createsContact;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('companyId')]);
|
||||
|
||||
$contact = new ContactObject(
|
||||
$company->reference,
|
||||
$request->input('contactNumber'),
|
||||
$company->email,
|
||||
$company->wechat_id
|
||||
);
|
||||
|
||||
$this->createContactProcessor->execute($contact, $company);
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($company));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Companies;
|
||||
|
||||
use App\Classes\Modules\Companies\ControllersLogic\CreateCompanyContactNumberLogic;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateCompanyContactNumberController extends Controller
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CreateCompanyContactNumberLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, CreateCompanyContactNumberLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto" v-if="item.contact">
|
||||
<!-- <div class="col-auto" v-if="item.contact"> -->
|
||||
<div class="col-auto">
|
||||
<div class="row align-items-center m-b-5">
|
||||
<div class="col">
|
||||
<h6 class="no-margin fs-12">Contact Number</h6>
|
||||
@@ -122,7 +123,7 @@
|
||||
<change-customer-contact-number-form-component :section="'customerProfileSection'" :data="item"></change-customer-contact-number-form-component>
|
||||
</modal-component>
|
||||
<h6 class="no-margin">
|
||||
{{item.contact.phone}}
|
||||
{{item?.contact?.phone || 'N/A'}}
|
||||
<div class="btn btn-xs b-rad-none pointer requestModal d-inline rounded no-border hover-primary bg-transparent" data-type="changeCustomerContactNumber" v-if="$store.getters.isAdmin">
|
||||
<i class="fa fa-edit pointer fa-fw fs-15 m-l-5"></i>
|
||||
</div>
|
||||
|
||||
+16
-4
@@ -3,7 +3,7 @@
|
||||
<div class="col bg-white padding-40 b-rad-lg">
|
||||
<div class="row m-b-10">
|
||||
<div class="col text-center">
|
||||
<h3>Edit Contact Number</h3>
|
||||
<h3>{{ isEdit ? 'Edit Contact Number' : 'Add Contact Number' }}</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@@ -32,12 +32,20 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
parameters: {
|
||||
parameters: this.data.contact ? {
|
||||
id: this.data.contact.id,
|
||||
contactNumber: this.data.contact.phone,
|
||||
} : {
|
||||
contactNumber: '',
|
||||
companyId: this.data.id,
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isEdit() {
|
||||
return !!this.data.contact;
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
parameters: {
|
||||
contactNumber: {
|
||||
@@ -47,10 +55,14 @@
|
||||
},
|
||||
methods: {
|
||||
submitForm() {
|
||||
this.submit(this.route('api.company.update.contactNumber', this.data.id), 'put', this.section, true, true)
|
||||
const route = this.isEdit
|
||||
? this.route('api.company.update.contactNumber', this.data.id)
|
||||
: this.route('api.company.create.contactNumber');
|
||||
|
||||
this.submit(route, this.isEdit ? 'put' : 'post', this.section, true, true);
|
||||
}
|
||||
},
|
||||
mixins: [modalFormHandler]
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -11,6 +11,7 @@ Route::group(['prefix' => 'company', 'as' => 'company.', 'namespace' => 'Compani
|
||||
Route::put('/name-and-debtor/update/{id}', 'UpdateCompanyNameAndDebtorController@update')->name('update.nameAndDebtor');
|
||||
Route::post('/update-credit-term/{id}', 'UpdateCompanyCreditTermStatusController@update')->name('update.creditterm.status');
|
||||
Route::put('/contact-number/update/{id}', 'UpdateCompanyContactNumberController@update')->name('update.contactNumber');
|
||||
Route::post('/contact-number/create', 'CreateCompanyContactNumberController@create')->name('create.contactNumber');
|
||||
Route::put('/type/update/{id}', 'UpdateCompanyTypeController@create')->name('update.type');
|
||||
|
||||
Route::post('/team/create', 'AddNewMemberController@create')->name('team.create');
|
||||
|
||||
Reference in New Issue
Block a user