mirror of
https://gitlab.com/uldvstar/exchange-2.0.git
synced 2026-08-19 04:24:16 +00:00
Merge branch 'company_bank' into 'master'
Company bank See merge request CIEFWorldwideSdnBhd/exchange-2.0!9
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\CompanyBanks\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\CompanyBanks\Standards\Rules\CanCreateCompanyBank;
|
||||
use App\Classes\Modules\CompanyBanks\Services\CreatesCompanyBank;
|
||||
use App\Classes\Modules\CompanyBanks\DataTransferObjects\CompanyBankObject;
|
||||
use App\Http\Resources\CompanyBankResource;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateCompanyBankLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Company Bank',
|
||||
'message' => 'You have successfully created a new Company Bank'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateCompanyBank */
|
||||
private $canCreateCompanyBank;
|
||||
|
||||
/** @var CreatesCompanyBank */
|
||||
private $createsCompanyBank;
|
||||
|
||||
/**
|
||||
* CreateSegmentLogic constructor.
|
||||
* @param CanCreateCompanyBank $canCreateCompanyBank
|
||||
* @param CreatesCompanyBank $createsCompanyBank
|
||||
*/
|
||||
public function __construct(
|
||||
CanCreateCompanyBank $canCreateCompanyBank,
|
||||
CreatesCompanyBank $createsCompanyBank
|
||||
)
|
||||
{
|
||||
$this->canCreateCompanyBank = $canCreateCompanyBank;
|
||||
$this->createsCompanyBank = $createsCompanyBank;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$company_bank_object = new CompanyBankObject(
|
||||
$request->input('country_id'),
|
||||
$request->input('company_id'),
|
||||
$request->input('bank_name'),
|
||||
$request->input('holder_name'),
|
||||
$request->input('account_no'),
|
||||
$request->input('type'),
|
||||
$request->input('default')
|
||||
);
|
||||
$this->canCreateCompanyBank->passes($company_bank_object);
|
||||
$company_bank_query = $this->createsCompanyBank->execute($company_bank_object);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new CompanyBankResource($company_bank_query));
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\CompanyBanks\ControllersLogic;
|
||||
|
||||
use App\Http\Resources\CompanyBankResource;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\CompanyBanks\Services\FetchesCompanyBank;
|
||||
|
||||
use App\Classes\Modules\CompanyBanks\Standards\Rules\CanDeleteCompanyBank;
|
||||
use App\Classes\Modules\CompanyBanks\Services\DeletesCompanyBank;
|
||||
use App\Classes\Modules\CompanyBanks\DataTransferObjects\SegmentObject;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class DeleteCompanyBankLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Delete Company Bank',
|
||||
'message' => 'You have successfully deleted the Company Bank'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanDeleteCompanyBank */
|
||||
private $canDeleteCompanyBank;
|
||||
|
||||
/** @var DeletesCompanyBank */
|
||||
private $deletesCompanyBank;
|
||||
|
||||
/** @var FetchesCompanyBank */
|
||||
private $fetchesCompanyBank;
|
||||
|
||||
/**
|
||||
* UpdateStandardSegmentConstantLogic constructor.
|
||||
* @param CanUpdateSegment $canDeleteCompanyBank
|
||||
* @param UpdatesSegment $deletesSegment
|
||||
* @param FetchesCompanyBank $fetchesCompanyBank
|
||||
*/
|
||||
public function __construct(
|
||||
CanDeleteCompanyBank $canDeleteCompanyBank,
|
||||
DeletesCompanyBank $deletesCompanyBank,
|
||||
FetchesCompanyBank $fetchesCompanyBank
|
||||
)
|
||||
{
|
||||
$this->canDeleteCompanyBank = $canDeleteCompanyBank;
|
||||
$this->deletesCompanyBank = $deletesCompanyBank;
|
||||
$this->fetchesCompanyBank = $fetchesCompanyBank;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$segment_query = $this->fetchesCompanyBank->execute(['id' => $request->route('id')]);
|
||||
$this->canDeleteCompanyBank->passes();
|
||||
$this->deletesCompanyBank->execute($segment_query);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new CompanyBankResource($segment_query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\CompanyBanks\ControllersLogic;
|
||||
|
||||
use App\Http\Resources\CompanyBankResource;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\CompanyBanks\Services\FetchesCompanyBank;
|
||||
|
||||
use App\Classes\Modules\CompanyBanks\Standards\Rules\CanUpdateCompanyBank;
|
||||
use App\Classes\Modules\CompanyBanks\Services\UpdatesCompanyBank;
|
||||
use App\Classes\Modules\CompanyBanks\DataTransferObjects\CompanyBankObject;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateCompanyBankLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Company Bank',
|
||||
'message' => 'You have successfully updated the Company Bank'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateCompanyBank */
|
||||
private $canUpdateCompanyBank;
|
||||
|
||||
/** @var UpdatesCompanyBank */
|
||||
private $updatesCompanyBank;
|
||||
|
||||
/** @var FetchesCompanyBank */
|
||||
private $fetchesSegment;
|
||||
|
||||
/**
|
||||
* UpdateStandardSegmentConstantLogic constructor.
|
||||
* @param CanUpdateCompanyBank $canUpdateCompanyBank
|
||||
* @param UpdatesCompanyBank $updatesCompanyBank
|
||||
* @param FetchesCompanyBank $fetchesSegment
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateCompanyBank $canUpdateCompanyBank,
|
||||
UpdatesCompanyBank $updatesCompanyBank,
|
||||
FetchesCompanyBank $fetchesSegment
|
||||
)
|
||||
{
|
||||
$this->canUpdateCompanyBank = $canUpdateCompanyBank;
|
||||
$this->updatesCompanyBank = $updatesCompanyBank;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$company_bank_query = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
||||
|
||||
$company_bank_object = new CompanyBankObject(
|
||||
$company_bank_query->country_id,
|
||||
$company_bank_query->company_id,
|
||||
$request->input('bank_name'),
|
||||
$request->input('holder_name'),
|
||||
$request->input('account_no'),
|
||||
$company_bank_query->type,
|
||||
$company_bank_query->default
|
||||
);
|
||||
$this->canUpdateCompanyBank->passes($company_bank_object);
|
||||
$company_bank_query = $this->updatesCompanyBank->execute($company_bank_query, $company_bank_object);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new CompanyBankResource($company_bank_query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\CompanyBanks\DataTransferObjects;
|
||||
|
||||
use App\Classes\Interfaces\DataTransferObject;
|
||||
|
||||
class CompanyBankObject implements DataTransferObject
|
||||
{
|
||||
/** @var string|null */
|
||||
private $country_id;
|
||||
private $company_id;
|
||||
private $bank_name;
|
||||
private $holder_name;
|
||||
private $account_no;
|
||||
private $type;
|
||||
private $default;
|
||||
|
||||
/**
|
||||
* CompanyBankObject constructor.
|
||||
* @param int|null $country_id
|
||||
* @param int|null $company_id
|
||||
* @param string|null $bank_name
|
||||
* @param string|null $holder_name
|
||||
* @param string|null $account_no
|
||||
* @param int|null $type
|
||||
* @param int|null $default
|
||||
*/
|
||||
public function __construct(
|
||||
?int $country_id,
|
||||
?int $company_id,
|
||||
?string $bank_name,
|
||||
?string $holder_name,
|
||||
?string $account_no,
|
||||
?int $type,
|
||||
?int $default
|
||||
)
|
||||
{
|
||||
$this->country_id = $country_id;
|
||||
$this->company_id = $company_id;
|
||||
$this->bank_name = $bank_name;
|
||||
$this->holder_name = $holder_name;
|
||||
$this->account_no = $account_no;
|
||||
$this->type = $type;
|
||||
$this->default = $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCountryId(): ?int
|
||||
{
|
||||
return $this->country_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCompanyId(): ?int
|
||||
{
|
||||
return $this->company_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBankName(): ?string
|
||||
{
|
||||
return $this->bank_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHolderName(): ?string
|
||||
{
|
||||
return $this->holder_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccountNo(): ?string
|
||||
{
|
||||
return $this->account_no;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getType(): ?int
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDefault(): ?int
|
||||
{
|
||||
return $this->default;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\CompanyBanks\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\CompanyBanks\DataTransferObjects\CompanyBankObject;
|
||||
use App\Models\CompanyBank;
|
||||
|
||||
class CreatesCompanyBank extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param CompanyBankObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyBankObject $object) {
|
||||
$model = new CompanyBank();
|
||||
$model->country_id = $object->getCountryId();
|
||||
$model->company_id = $object->getCompanyId();
|
||||
$model->bank_name = $object->getBankName();
|
||||
$model->holder_name = $object->getHolderName();
|
||||
$model->account_no = $object->getAccountNo();
|
||||
$model->type = $object->getType();
|
||||
$model->default = $object->getDefault();
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\CompanyBanks\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractDeleteRecord;
|
||||
use App\Models\CompanyBank;
|
||||
|
||||
class DeletesCompanyBank extends AbstractDeleteRecord
|
||||
{
|
||||
|
||||
public function execute(CompanyBank $model) {
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\CompanyBanks\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\CompanyBank;
|
||||
|
||||
class FetchesCompanyBank extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var CompanyBank */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* FetchesUser constructor.
|
||||
* @param CompanyBank $repository
|
||||
*/
|
||||
public function __construct(CompanyBank $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\CompanyBanks\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\CompanyBanks\DataTransferObjects\CompanyBankObject;
|
||||
use App\Models\CompanyBank;
|
||||
|
||||
class UpdatesCompanyBank extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param CompanyBankObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyBank $model, CompanyBankObject $object)
|
||||
{
|
||||
$model->bank_name = $object->getBankName();
|
||||
$model->holder_name = $object->getHolderName();
|
||||
$model->account_no = $object->getAccountNo();
|
||||
$model->default = $object->getDefault();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\CompanyBanks\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\CompanyBanks\DataTransferObjects\SegmentObject;
|
||||
use App\Classes\Modules\CompanyBanks\Standards\Validators\CompanyBankValidation;
|
||||
|
||||
class CanCreateCompanyBank extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var CompanyBankValidation */
|
||||
private $companyBankValidation;
|
||||
|
||||
/**
|
||||
* CanCreateCompanyBank constructor.
|
||||
* @param CompanyBankValidation $companyBankValidation
|
||||
*/
|
||||
public function __construct(CompanyBankValidation $companyBankValidation)
|
||||
{
|
||||
$this->companyBankValidation = $companyBankValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
if (!\Auth::user()->can('add company_bank')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->companyBankValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\CompanyBanks\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\CompanyBanks\DataTransferObjects\CompanyBankObject;
|
||||
|
||||
class CanDeleteCompanyBank extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
if (!\Auth::user()->can('delete company_bank')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CompanyBankObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param CompanyBankObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\CompanyBanks\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\CompanyBanks\DataTransferObjects\CompanybankObject;
|
||||
use App\Classes\Modules\CompanyBanks\Standards\Validators\CompanybankValidation;
|
||||
|
||||
class CanUpdateCompanyBank extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var CompanyBankValidation */
|
||||
private $CompanyBankValidation;
|
||||
|
||||
/**
|
||||
* CanCreateAddress constructor.
|
||||
* @param CompanyBankValidation $CompanyBankValidation
|
||||
*/
|
||||
public function __construct(CompanyBankValidation $CompanyBankValidation)
|
||||
{
|
||||
$this->CompanyBankValidation = $CompanyBankValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
if (!\Auth::user()->can('edit company_bank')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CompanyBankValidation $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->CompanyBankValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CompanyBankValidation $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\CompanyBanks\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\CompanyBanks\DataTransferObjects\CompanyBankObject;
|
||||
|
||||
class CompanyBankValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param CompanyBankObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'country_id' => $object->getCountryId(),
|
||||
'company_id' => $object->getCompanyId(),
|
||||
'bank_name' => $object->getBankName(),
|
||||
'holder_name' => $object->getHolderName(),
|
||||
'account_no' => $object->getAccountNo(),
|
||||
'type' => $object->getType(),
|
||||
'default' => $object->getDefault(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'country_id' => 'required',
|
||||
'company_id' => 'required',
|
||||
'bank_name' => 'required',
|
||||
'holder_name' => 'required',
|
||||
'account_no' => 'required',
|
||||
'type' => 'required',
|
||||
'default' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class BusinessType {
|
||||
public const IMPORTER = 1;
|
||||
public const FREIGHT_FORARDER = 2;
|
||||
public const CURRENCY_VENDOR = 3;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class CompanyBankType {
|
||||
public const PERSONAL = 1;
|
||||
public const EXTERNAL = 2;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\CompanyBanks;
|
||||
|
||||
use App\Classes\Modules\CompanyBanks\ControllersLogic\CreateCompanyBankLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateCompanyBankController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CreateCompanyBankLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, CreateCompanyBankLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\CompanyBanks;
|
||||
|
||||
use App\Classes\Modules\CompanyBanks\ControllersLogic\DeleteCompanyBankLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteCompanyBankController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param DeleteCompanyBankLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function delete(Request $request, DeleteCompanyBankLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\CompanyBanks;
|
||||
|
||||
use App\Classes\Modules\CompanyBanks\ControllersLogic\UpdateCompanyBankLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyBankController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateCompanyBankLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateCompanyBankLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CompanyBankResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'country_id' => $this->country_id,
|
||||
'company_id' => $this->company_id,
|
||||
'bank_name' => $this->bank_name,
|
||||
'holder_name' => $this->holder_name,
|
||||
'account_no' => $this->account_no,
|
||||
'type' => $this->type,
|
||||
'default' => $this->default,
|
||||
'status' => $this->status,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
/**
|
||||
* Class CompanyBank
|
||||
* @package App\Models
|
||||
* @version August 4, 2020, 4:36 am
|
||||
*
|
||||
* @property \App\Models\Country country_id
|
||||
* @property \App\Models\Company company_id
|
||||
* @property string bank_name
|
||||
* @property string holder_name
|
||||
* @property string account_no
|
||||
* @property int type
|
||||
* @property int default
|
||||
* @property int status
|
||||
*/
|
||||
class CompanyBank extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'company_banks';
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
**/
|
||||
public function country(): HasOne
|
||||
{
|
||||
return $this->hasOne(Country::class, 'country_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
**/
|
||||
public function company(): HasOne
|
||||
{
|
||||
return $this->hasOne(Company::class, 'company_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -15,9 +15,10 @@ class CreateCompaniesTable extends Migration
|
||||
{
|
||||
Schema::create('companies', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->nullable();
|
||||
$table->string('reference')->nullable();
|
||||
$table->integer('type')->nullable();
|
||||
$table->string('name');
|
||||
$table->string('reference');
|
||||
$table->integer('type');
|
||||
$table->integer('business_type')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateCompanyBanksTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('company_banks', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigInteger('country_id')->unsigned()->nullable();
|
||||
$table->foreign('country_id')->references('id')->on('countries')->onDelete('cascade');
|
||||
$table->bigInteger('company_id')->unsigned()->nullable();
|
||||
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
|
||||
$table->string('bank_name');
|
||||
$table->string('holder_name');
|
||||
$table->string('account_no');
|
||||
$table->integer('type');
|
||||
$table->integer('default');
|
||||
$table->integer('status')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('company_banks');
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,11 @@ class AdminUserPermissionsTableSeeder extends Seeder
|
||||
Permission::create(['name' => 'edit segment_constant', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'delete segment_constant', 'guard_name' => 'web']);
|
||||
|
||||
Permission::create(['name' => 'view company_bank', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'add company_bank', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'edit company_bank', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'delete company_bank', 'guard_name' => 'web']);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
$shadow_admin_role = Role::create([
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CompaniesTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('companies')->insert([
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => 'CIEF SDN BHD',
|
||||
'reference' => 'CIEF',
|
||||
'type' => 2,
|
||||
'business_type' => 1,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s')
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,8 @@ class DatabaseSeeder extends Seeder
|
||||
|
||||
$this->call(SegmentsTableSeeder::class);
|
||||
$this->call(SegmentConstantsTableSeeder::class);
|
||||
|
||||
$this->call(CompaniesTableSeeder::class);
|
||||
|
||||
// Admin
|
||||
$this->call(AdminUserTableSeeder::class);
|
||||
|
||||
@@ -24,6 +24,8 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function
|
||||
|
||||
require __DIR__ . '/segment.php';
|
||||
|
||||
require __DIR__ . '/company_bank.php';
|
||||
|
||||
Route::group(['middleware' => 'valid.token'], function () {
|
||||
require __DIR__ . '/crud.php';
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user