mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
Merge remote-tracking branch 'origin/development' into development
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompany;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyModuleName;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompany;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
@@ -35,17 +36,22 @@ class UpdateCompanyLogic extends AbstractControllerLogic
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var UpdatesCompanyModuleName */
|
||||
private $updatesCompanyModuleName;
|
||||
|
||||
/**
|
||||
* UpdateCompanyControllersLogic constructor.
|
||||
* @param CanUpdateCompany $canUpdateCompany
|
||||
* @param UpdatesCompany $updatesCompany
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param UpdatesCompanyModuleName $updatesCompanyModuleName
|
||||
*/
|
||||
public function __construct(CanUpdateCompany $canUpdateCompany, UpdatesCompany $updatesCompany, FetchesCompany $fetchesCompany)
|
||||
public function __construct(CanUpdateCompany $canUpdateCompany, UpdatesCompany $updatesCompany, FetchesCompany $fetchesCompany, UpdatesCompanyModuleName $updatesCompanyModuleName)
|
||||
{
|
||||
$this->canUpdateCompany = $canUpdateCompany;
|
||||
$this->updatesCompany = $updatesCompany;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->updatesCompanyModuleName = $updatesCompanyModuleName;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,23 +62,17 @@ class UpdateCompanyLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
$object = new CompanyObject($request->input('name'), $request->input('reference'), $request->input('type'));
|
||||
|
||||
$object = new CompanyObject($request->input('reference_no'), $request->input('name'), $request->input('type'));
|
||||
$this->canUpdateCompany->passes($object);
|
||||
|
||||
$this->canUpdateCompany->passes($object);
|
||||
$query = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
|
||||
$query = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
$query = $this->updatesCompany->execute($query, $object);
|
||||
|
||||
$query = $this->updatesCompany->execute($query, $object);
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($query));
|
||||
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
$this->updatesCompanyModuleName->execute($query->companyModules()->first(), $object->getName());
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($query));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyModuleObject;
|
||||
use App\Models\CompanyModule;
|
||||
|
||||
class UpdatesCompanyModuleName extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param CompanyModule $model
|
||||
* @param CompanyModuleObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyModule $model, string $name)
|
||||
{
|
||||
$model->name = $name;
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,8 @@ class CompanyValidation extends AbstractValidation
|
||||
{
|
||||
return [
|
||||
'company_name' => $object->getName(),
|
||||
'company_reference' => $object->getReference()
|
||||
'company_reference' => $object->getReference(),
|
||||
'type' => $object->getType()
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,11 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
name: this.data.name,
|
||||
parameters: {
|
||||
name: this.data.name,
|
||||
reference: this.data.reference,
|
||||
type: this.data.type,
|
||||
},
|
||||
};
|
||||
},
|
||||
validations: {
|
||||
@@ -25,10 +29,8 @@
|
||||
name: { required },
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
submitForm() {
|
||||
this.parameters.name = this.data.name;
|
||||
this.submit(this.route('api.company.update', this.data.id), 'put', '', false, false);
|
||||
this.$emit('submit');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user