mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Update: laravel 8 to 12, php 7.3 to php 8.3, Jenkinsfile, Unit/Feature testing, vapor, docker
This commit is contained in:
@@ -4,7 +4,6 @@ namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class IsNotFullyRefunded implements Filter
|
||||
{
|
||||
@@ -19,6 +18,6 @@ class IsNotFullyRefunded implements Filter
|
||||
return $builder->withSum(['transactions as total_refund_amount' => function($q) {
|
||||
$q->refunds()->where('status', ApprovalStatus::APPROVED);
|
||||
}], 'original_amount')
|
||||
->having('total_refund_amount', '<', DB::raw('original_amount'));
|
||||
->havingRaw('total_refund_amount < original_amount');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class IsPartialRefund implements Filter
|
||||
{
|
||||
@@ -17,9 +16,9 @@ class IsPartialRefund implements Filter
|
||||
{
|
||||
return $builder->whereHas('owner', function ($q) use ($value) {
|
||||
if ($value) {
|
||||
$q->where('original_amount', '!=', DB::raw('transactions.original_amount'));
|
||||
$q->whereRaw('original_amount != transactions.original_amount');
|
||||
} else {
|
||||
$q->where('original_amount', DB::raw('transactions.original_amount'));
|
||||
$q->whereRaw('original_amount = transactions.original_amount');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class SendWelcomeVoucherEmail implements ShouldQueue
|
||||
{
|
||||
$currentDatetime = Carbon::now();
|
||||
$dateToCompare = Carbon::parse($this->voucher->end_date);
|
||||
if (!$this->user->hasAttribute($this->voucher->code."_EMAIL_COUNT")
|
||||
if (!$this->user->hasCustomAttribute($this->voucher->code."_EMAIL_COUNT")
|
||||
&& $this->user->rewards->where('voucher_id', $this->voucher->id)->count() > 0
|
||||
&& $currentDatetime->isBefore($dateToCompare))
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Accounts\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\UserObject;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UserCreateValidation extends AbstractValidation
|
||||
{
|
||||
@@ -28,9 +29,9 @@ class UserCreateValidation extends AbstractValidation
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required',
|
||||
'email' => 'required|unique:users',
|
||||
'password' => 'required',
|
||||
'name' => 'required',
|
||||
'email' => ['required', Rule::unique('users')],
|
||||
'password' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Accounts\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\RegistrationObject;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UserRegistrationValidation extends AbstractValidation
|
||||
{
|
||||
@@ -32,7 +33,7 @@ class UserRegistrationValidation extends AbstractValidation
|
||||
{
|
||||
return [
|
||||
'name' => 'required',
|
||||
'email' => 'required|email|max:255|unique:users,email',
|
||||
'email' => ['required', 'email', 'max:255', Rule::unique('users', 'email')],
|
||||
'password' => 'required|min:6|confirmed',
|
||||
'type' => 'required',
|
||||
'status' => 'required'
|
||||
|
||||
@@ -56,7 +56,7 @@ class UpdateCompanyLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new CompanyObject($request->input('name'), $request->input('reference'), $request->input('type'));
|
||||
$object = new CompanyObject($request->input('name'), $request->input('reference'), $request->input('business_type'), $request->input('type'));
|
||||
|
||||
$this->canUpdateCompany->passes($object);
|
||||
|
||||
@@ -67,4 +67,4 @@ class UpdateCompanyLogic extends AbstractControllerLogic
|
||||
return $this->resourceResponse(new CompanyResource($query));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Classes\ValueObjects\Constants\FileType;
|
||||
use Illuminate\Support\Str;
|
||||
use Intervention\Image\ImageManager;
|
||||
use Intervention\Image\Drivers\Gd\Driver;
|
||||
|
||||
class FileObject implements DataTransferObject
|
||||
{
|
||||
@@ -28,7 +29,13 @@ class FileObject implements DataTransferObject
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return in_array($this->getExtension(), ['pdf', 'excel', 'text']) ? $this->data : (new imageManager())->make($this->data);
|
||||
// intervention/image v2: old
|
||||
//return in_array($this->getExtension(), ['pdf', 'excel', 'text']) ? $this->data : (new imageManager())->make($this->data);
|
||||
|
||||
// intervention/image v3: new
|
||||
return in_array($this->getExtension(), ['pdf', 'excel', 'text'])
|
||||
? $this->data
|
||||
: (new ImageManager(new Driver()))->read($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,7 +60,7 @@ class FileObject implements DataTransferObject
|
||||
*/
|
||||
public function getExtension(): string
|
||||
{
|
||||
if(array_key_exists($this->getMimeType(), FileType::EXTENSION)){
|
||||
if (array_key_exists($this->getMimeType(), FileType::EXTENSION)) {
|
||||
return FileType::EXTENSION[$this->getMimeType()];
|
||||
}
|
||||
|
||||
@@ -66,9 +73,10 @@ class FileObject implements DataTransferObject
|
||||
*/
|
||||
public function getDecodedData(): string
|
||||
{
|
||||
// intervention/image v3: Use encode()->toDataUri() instead of encode('data-url')->encoded
|
||||
return in_array($this->getExtension(), ['pdf', 'excel', 'text']) ?
|
||||
base64_decode((explode('base64,', $this->getData()))[1]):
|
||||
$this->getData()->encode('data-url')->encoded;
|
||||
base64_decode((explode('base64,', $this->getData()))[1]) :
|
||||
$this->getData()->encode()->toDataUri();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,7 +32,8 @@ class ConvertsBase64ToFile
|
||||
* @return array
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function convert($files = []){
|
||||
public function convert($files = [])
|
||||
{
|
||||
foreach ($files as $file) {
|
||||
|
||||
$object = new FileObject($file);
|
||||
@@ -48,41 +49,47 @@ class ConvertsBase64ToFile
|
||||
* @param FileObject $file
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
private function generatePDF(FileObject $file){
|
||||
private function generatePDF(FileObject $file)
|
||||
{
|
||||
|
||||
$filePath = $this->generateFile($file);
|
||||
$this->updateFiles($file, [ 'original' => [ 'file' => $filePath ] ]);
|
||||
$this->updateFiles($file, ['original' => ['file' => $filePath]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FileObject $file
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
private function generateImage(FileObject $file){
|
||||
private function generateImage(FileObject $file)
|
||||
{
|
||||
|
||||
$fileInfo = [];
|
||||
|
||||
foreach (['original' => null, 'large' => 800, 'medium' => 480, 'small' => 320] as $size => $value) {
|
||||
$suffix = $size !== 'original' ? '_'.$size : '';
|
||||
$suffix = $size !== 'original' ? '_' . $size : '';
|
||||
|
||||
if($size !== 'original') {
|
||||
$thumbnail = $file->getData()->widen($value, function ($constraint) {
|
||||
if ($size !== 'original') {
|
||||
// intervention/image v2: old
|
||||
// $thumbnail = $file->getData()->widen($value, function ($constraint) {
|
||||
// $constraint->upsize();
|
||||
// })->heighten($value, function ($constraint) {
|
||||
// $constraint->upsize();
|
||||
// });
|
||||
// $file->setData($thumbnail->encode('data-url')->encoded);
|
||||
|
||||
$constraint->upsize();
|
||||
|
||||
})->heighten($value, function ($constraint) {
|
||||
// intervention/image v3: Use scaleDown() instead of widen()/heighten()
|
||||
// scaleDown() maintains aspect ratio and prevents upsizing by default
|
||||
$thumbnail = $file->getData()->scaleDown(width: $value, height: $value);
|
||||
|
||||
$constraint->upsize();
|
||||
|
||||
});
|
||||
|
||||
$file->setData($thumbnail->encode('data-url')->encoded);
|
||||
// intervention/image v3: Use encode()->toDataUri() instead of encode('data-url')->encoded
|
||||
$file->setData($thumbnail->encode()->toDataUri());
|
||||
}
|
||||
|
||||
|
||||
$filePath = $this->generateFile($file, $suffix);
|
||||
|
||||
$fileInfo[] = [ $size => [ 'file' => $filePath, 'width' => $file->getData()->width(), 'height' => $file->getData()->height() ]];
|
||||
$fileInfo[] = [$size => ['file' => $filePath, 'width' => $file->getData()->width(), 'height' => $file->getData()->height()]];
|
||||
|
||||
|
||||
}
|
||||
@@ -97,16 +104,16 @@ class ConvertsBase64ToFile
|
||||
* @return string
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
private function generateFile(FileObject $file, string $suffix = '') {
|
||||
private function generateFile(FileObject $file, string $suffix = '')
|
||||
{
|
||||
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
$filePath = 'documents/'.$this->path.'/'.$file->getFileName().$suffix.'.'.$file->getExtension();
|
||||
if ($filesystemDriver === 's3') {
|
||||
$filePath = 'documents/' . $this->path . '/' . $file->getFileName() . $suffix . '.' . $file->getExtension();
|
||||
Storage::put($filePath, $file->getDecodedData(), 's3');
|
||||
return $filePath;
|
||||
}
|
||||
else{
|
||||
$filePath = $this->path.'/'.$file->getFileName().$suffix.'.'.$file->getExtension();
|
||||
} else {
|
||||
$filePath = $this->path . '/' . $file->getFileName() . $suffix . '.' . $file->getExtension();
|
||||
Storage::disk('documents')->put($filePath, $file->getDecodedData());
|
||||
return $filePath;
|
||||
}
|
||||
@@ -117,10 +124,11 @@ class ConvertsBase64ToFile
|
||||
* @param array $fileInfo
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
private function updateFiles(FileObject $file, array $fileInfo){
|
||||
private function updateFiles(FileObject $file, array $fileInfo)
|
||||
{
|
||||
$this->filesInfo[] = json_encode([
|
||||
'path' => $this->path,
|
||||
'filename' => $file->getFileName().'.'.$file->getExtension(),
|
||||
'filename' => $file->getFileName() . '.' . $file->getExtension(),
|
||||
'mime_type' => $file->getMimeType(),
|
||||
'extension' => $file->getExtension(),
|
||||
'file_info' => $fileInfo
|
||||
|
||||
@@ -19,14 +19,19 @@ class CreatesFiles extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
$models = [];
|
||||
|
||||
// foreach ($object->getFiles() as $file) {
|
||||
// $model = new File(['file' => $file]);
|
||||
// $models[] = $this->handler($document->files(), $model);
|
||||
// }
|
||||
|
||||
foreach ($object->getFiles() as $file) {
|
||||
|
||||
$model = new File(['file' => $file]);
|
||||
$fileData = is_string($file) ? json_decode($file, true) : $file;
|
||||
$model = new File(['file' => $fileData]);
|
||||
$models[] = $this->handler($document->files(), $model);
|
||||
|
||||
}
|
||||
|
||||
return $models;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ class CreatesConstant extends AbstractUpdateRelationshipRecord
|
||||
$model = new SegmentConstant();
|
||||
$model->name = $object->getName();
|
||||
$model->reference = $object->getReference();
|
||||
$model->detail = json_encode($object->getDetail());
|
||||
$model->detail = $object->getDetail();
|
||||
|
||||
return $this->handler($segment->constants(), $model);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class UpdatesConstant extends AbstractUpdateRecord
|
||||
{
|
||||
$model->name = $object->getName();
|
||||
$model->reference = $object->getReference();
|
||||
$model->detail = json_encode($object->getDetail());
|
||||
$model->detail = $object->getDetail();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
use App\Classes\Modules\Segments\Standards\Validators\SegmentValidation;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CanCreateSegment extends AbstractRule
|
||||
{
|
||||
@@ -28,7 +29,10 @@ class CanCreateSegment extends AbstractRule
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
if (!Auth::user()->can('add segment')) {
|
||||
/** @var \App\Models\User $user */
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user->can('add segment')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -53,4 +57,4 @@ class CanCreateSegment extends AbstractRule
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,8 +139,7 @@ class CreateInvoiceTransactionV2Processor
|
||||
->complete()
|
||||
->first();
|
||||
|
||||
if(!$purchaseOrder){
|
||||
//was use for $generateEInvoiceRefund true
|
||||
if(!$purchaseOrder && $generateEInvoiceRefund){
|
||||
$purchaseOrder = $booking->transactions()
|
||||
->where('type', TransactionType::PURCHASE_ORDER)
|
||||
->where('status', ApprovalStatus::PENDING_SUBMISSION)
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use ZipArchive;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
//Commands Version 2: Laravel Vapor/AWS
|
||||
$isEnabled = env('COMMANDS_V2_ENABLED', false);
|
||||
if($isEnabled){
|
||||
// $schedule->command('dummy-command')
|
||||
// ->everyFiveMinutes()
|
||||
// ->withoutOverlapping();
|
||||
|
||||
$schedule->command('housekeeping-s3-files-command')
|
||||
->dailyAt('01:00')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('password-reset-token-expriration-check-command')
|
||||
->everySixHours()
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('new-user-registration-expire-check-command')
|
||||
->everySixHours()
|
||||
->withoutOverlapping();
|
||||
|
||||
if(env('APP_ENV') === 'production'){
|
||||
$schedule->command('email-do-to-vt-command')
|
||||
->dailyAt('10:00')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('seasonal-segmant-company-remove-command')
|
||||
->dailyAt('01:00')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('delete-bulk-download-files-command')
|
||||
->hourly()
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('booking-expired-command')
|
||||
->dailyAt('02:00')
|
||||
->withoutOverlapping();
|
||||
|
||||
// DISABLED BY DEFAULT
|
||||
// $schedule->command('purchase-order-autofill-command')
|
||||
// ->dailyAt('03:00')
|
||||
// ->withoutOverlapping();
|
||||
|
||||
// Push company module to Lark
|
||||
$schedule->command('lark:push-company-module')
|
||||
->hourly()
|
||||
->withoutOverlapping();
|
||||
// Push booking module to Lark
|
||||
$schedule->command('lark:push-booking-module')
|
||||
->hourly()
|
||||
->withoutOverlapping();
|
||||
}
|
||||
}
|
||||
//Commands Version 1: Before Laravel Vapor/AWS
|
||||
else{
|
||||
// $schedule->command('inspire')->hourly();
|
||||
$schedule->command('mail:EmailDoToVTCommand')->dailyAt('10:00')->withoutOverlapping();
|
||||
|
||||
$schedule->command('seasonalSegmantCompany:remove')
|
||||
->dailyAt('01:00')
|
||||
->appendOutputTo(storage_path().'/logs/soft-delete-seasonal-segmant-company.log')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('delete:bulk-download-files')
|
||||
->hourly()
|
||||
->appendOutputTo(storage_path().'/logs/delete-bulk-download-files.log')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('booking:expired')
|
||||
->dailyAt('02:00')
|
||||
->appendOutputTo(storage_path().'/logs/expire-booking.log')
|
||||
->withoutOverlapping();
|
||||
|
||||
// $schedule->command('purchaseOrder:autoFill')
|
||||
// ->dailyAt('03:00')
|
||||
// ->withoutOverlapping();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use App\Classes\ValueObjects\Response\ApiResponseObject;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* @param \Throwable $exception
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function report(Throwable $exception)
|
||||
{
|
||||
parent::report($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Throwable $exception
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function render($request, Throwable $exception)
|
||||
{
|
||||
if ($exception instanceof MaintenanceModeException) {
|
||||
return response()
|
||||
->view('pages.errors.maintenance');
|
||||
}
|
||||
|
||||
if ($exception instanceof AuthenticationException) {
|
||||
return (new ApiResponseObject('Authentication', 'To keep your account secure we need to re-validate your account', HttpStatus::ACCESS_UNAUTHORISED))->handler();
|
||||
}
|
||||
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ class AWSImageUploadController extends Controller
|
||||
public function imageUploadPost(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
|
||||
'image' => 'required|image:allow_svg|mimes:jpeg,png,jpg,gif,svg|max:2048',
|
||||
]);
|
||||
|
||||
$imageName = time().'.'.$request->image->extension();
|
||||
|
||||
@@ -169,7 +169,7 @@ class ImportStatementInvoiceController
|
||||
}
|
||||
|
||||
if ($transaction && $transaction->count() == 0) {
|
||||
$transaction = Transaction::getReceiverWithJoinStatementTransactionAndOwner($row)->select('transactions.*')->where(DB::raw('FLOOR(statement_transactions.amount)'), floor($row['net_total']))->whereRaw("DATE(posting_date) = '$date'")->first();
|
||||
$transaction = Transaction::getReceiverWithJoinStatementTransactionAndOwner($row)->select('transactions.*')->whereRaw('FLOOR(statement_transactions.amount) = ?', [floor($row['net_total'])])->whereRaw("DATE(posting_date) = '$date'")->first();
|
||||
}
|
||||
|
||||
if ($transaction && $transaction->count() > 0) {
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use App\Http\Middleware\Authenticate;
|
||||
use App\Http\Middleware\CheckForMaintenanceMode;
|
||||
use App\Http\Middleware\EncryptCookies;
|
||||
use App\Http\Middleware\RedirectIfAuthenticated;
|
||||
use App\Http\Middleware\TrimStrings;
|
||||
use App\Http\Middleware\TrustProxies;
|
||||
use App\Http\Middleware\ValidateToken;
|
||||
use App\Http\Middleware\VerifyCsrfToken;
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
TrustProxies::class,
|
||||
\Fruitcake\Cors\HandleCors::class,
|
||||
CheckForMaintenanceMode::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\App\Http\Middleware\LogRequestPathMiddleware::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
'throttle:300,1',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\App\Http\Middleware\LogRequestPathMiddleware::class,
|
||||
],
|
||||
|
||||
'apipub' => [
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\App\Http\Middleware\LogRequestPathMiddleware::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'valid.token' => ValidateToken::class,
|
||||
'token.check' => \App\Http\Middleware\TokenCheckerMiddleware::class,
|
||||
'admin' => \App\Http\Middleware\EnsureUserIsAdmin::class, //cief maintenance
|
||||
];
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
@@ -19,5 +19,10 @@ class TrustProxies extends Middleware
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers = Request::HEADER_X_FORWARDED_ALL;
|
||||
protected $headers =
|
||||
Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
Request::HEADER_X_FORWARDED_PREFIX;
|
||||
}
|
||||
|
||||
@@ -7,23 +7,9 @@ use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use App\Classes\ValueObjects\Response\ApiResponseObject;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Tymon\JWTAuth\JWT;
|
||||
|
||||
class ValidateToken
|
||||
{
|
||||
/** @var JWT */
|
||||
private $manager;
|
||||
|
||||
/**
|
||||
* ValidateToken constructor.
|
||||
* @param JWT $manager
|
||||
*/
|
||||
public function __construct(JWT $manager)
|
||||
{
|
||||
$this->manager = $manager;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if jwt token is valid.
|
||||
*
|
||||
@@ -35,9 +21,9 @@ class ValidateToken
|
||||
{
|
||||
try {
|
||||
|
||||
if(!$this->manager->check()){ throw new AccessUnauthorisedException(); }
|
||||
if(!auth('api')->check()){ throw new AccessUnauthorisedException(); }
|
||||
|
||||
} catch (Exception $exception) {
|
||||
} catch (Exception) {
|
||||
|
||||
return (new ApiResponseObject('Authentication', 'To keep your account secure we need to re-validate your account', HttpStatus::ACCESS_UNAUTHORISED))->handler();
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Logging;
|
||||
|
||||
use Aws\CloudWatchLogs\CloudWatchLogsClient;
|
||||
use Maxbanton\Cwh\Handler\CloudWatch;
|
||||
use PhpNexus\Cwh\Handler\CloudWatch;
|
||||
use Monolog\Formatter\JsonFormatter;
|
||||
use Monolog\Logger;
|
||||
|
||||
|
||||
@@ -6,12 +6,21 @@ namespace App\Models;
|
||||
use App\Classes\General\Interfaces\Notifiable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
class AbstractModel extends Model implements Notifiable
|
||||
{
|
||||
use LogsActivity;
|
||||
protected static $logFillable = true;
|
||||
|
||||
/**
|
||||
* Get the options for logging activity.
|
||||
*/
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logFillable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphTo
|
||||
@@ -36,4 +45,4 @@ class AbstractModel extends Model implements Notifiable
|
||||
{
|
||||
return $this->MorphTo('causer');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,18 @@ class AccountStatement extends Model
|
||||
'mapped_rows',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'date_from' => 'date',
|
||||
'date_to' => 'date',
|
||||
];
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'date_from' => 'date',
|
||||
'date_to' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function account()
|
||||
{
|
||||
|
||||
+21
-11
@@ -9,22 +9,32 @@ use Illuminate\Database\Eloquent\Builder;
|
||||
* Class Address
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Country country_id
|
||||
* @property \App\Models\Company company_id
|
||||
* @property \App\Models\State state_id
|
||||
* @property \App\Models\District district_id
|
||||
* @property string postcode
|
||||
* @property string street_one
|
||||
* @property string street_two
|
||||
* @property integer billing_type
|
||||
* @property int $country_id
|
||||
* @property int $company_id
|
||||
* @property int $state_id
|
||||
* @property int $district_id
|
||||
* @property string $postcode
|
||||
* @property string $street_one
|
||||
* @property string $street_two
|
||||
* @property int $billing_type
|
||||
*/
|
||||
class Address extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'addresses';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
@@ -64,6 +74,6 @@ class Address extends AbstractModel
|
||||
*/
|
||||
public function scopeDefault(Builder $query)
|
||||
{
|
||||
return $query->where('billing', '=',true)->first();
|
||||
return $query->where('billing', '=', true)->first();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ class Affiliate extends AbstractModel
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'affiliates';
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected $fillable = [
|
||||
'code',
|
||||
@@ -24,12 +23,21 @@ class Affiliate extends AbstractModel
|
||||
'orders_count'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
'clicks_count' => 'integer',
|
||||
'registrations_count' => 'integer',
|
||||
'orders_count' => 'integer'
|
||||
];
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_active' => 'boolean',
|
||||
'clicks_count' => 'integer',
|
||||
'registrations_count' => 'integer',
|
||||
'orders_count' => 'integer',
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
|
||||
@@ -8,7 +8,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
/**
|
||||
* Class Announcement
|
||||
* @package App\Models
|
||||
*
|
||||
*/
|
||||
class Announcement extends AbstractModel
|
||||
{
|
||||
@@ -16,9 +15,6 @@ class Announcement extends AbstractModel
|
||||
|
||||
protected $table = 'announcements';
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
**/
|
||||
public function segments(): BelongsToMany
|
||||
{
|
||||
return $this->BelongsToMany(Segment::class);
|
||||
|
||||
+9
-10
@@ -14,22 +14,21 @@ use App\Classes\General\Interfaces\KeyValueInterface;
|
||||
* Class Bank
|
||||
* @package App\Models
|
||||
*
|
||||
* @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
|
||||
* @property int $country_id
|
||||
* @property int $company_id
|
||||
* @property string $bank_name
|
||||
* @property string $holder_name
|
||||
* @property string $account_no
|
||||
* @property int $type
|
||||
* @property int $default
|
||||
* @property int $status
|
||||
*/
|
||||
class Bank extends AbstractModel implements KeyValueInterface
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'company_id',
|
||||
|
||||
@@ -19,7 +19,17 @@ class BillGroup extends Model implements Documentable, Transactionable
|
||||
|
||||
protected $table = 'bill_groups';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
|
||||
+19
-9
@@ -19,13 +19,13 @@ use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
* Class Booking
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Company company_id
|
||||
* @property \App\Models\Bank transferable_bank_id
|
||||
* @property string marking
|
||||
* @property string reference
|
||||
* @property float fix_amount
|
||||
* @property int convertible_currency_id
|
||||
* @property int conversion_currency_id
|
||||
* @property int $company_id
|
||||
* @property int $transferable_bank_id
|
||||
* @property string $marking
|
||||
* @property string $reference
|
||||
* @property float $fix_amount
|
||||
* @property int $convertible_currency_id
|
||||
* @property int $conversion_currency_id
|
||||
*/
|
||||
class Booking extends AbstractModel implements Documentable, Transactionable, Voucherifiable, KeyValueInterface
|
||||
{
|
||||
@@ -35,7 +35,17 @@ class Booking extends AbstractModel implements Documentable, Transactionable, Vo
|
||||
|
||||
protected $table = 'bookings';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
@@ -106,7 +116,7 @@ class Booking extends AbstractModel implements Documentable, Transactionable, Vo
|
||||
*/
|
||||
public function bills(): hasManyDeep
|
||||
{
|
||||
return $this->hasManyDeep(Transaction::class, [Transaction::class.' as alias'], [['owner_type', 'owner_id'], ['owner_type', 'owner_id']], [null, null]);
|
||||
return $this->hasManyDeep(Transaction::class, [Transaction::class . ' as alias'], [['owner_type', 'owner_id'], ['owner_type', 'owner_id']], [null, null]);
|
||||
}
|
||||
|
||||
public function modelAttributes(): MorphMany
|
||||
|
||||
+19
-9
@@ -20,13 +20,13 @@ use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
* Class Company
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Country country_id
|
||||
* @property \App\Models\State state_id
|
||||
* @property \App\Models\District district_id
|
||||
* @property string postcode
|
||||
* @property string street_one
|
||||
* @property string street_two
|
||||
* @property integer billing_type
|
||||
* @property int $country_id
|
||||
* @property int $state_id
|
||||
* @property int $district_id
|
||||
* @property string $postcode
|
||||
* @property string $street_one
|
||||
* @property string $street_two
|
||||
* @property int $billing_type
|
||||
*/
|
||||
class Company extends AbstractModel implements Documentable
|
||||
{
|
||||
@@ -35,8 +35,18 @@ class Company extends AbstractModel implements Documentable
|
||||
|
||||
protected $table = 'companies';
|
||||
|
||||
protected $dates = ['deleted_at', 'created_at'];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
|
||||
+19
-12
@@ -10,12 +10,12 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* Class Contact
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Country country_id
|
||||
* @property \App\Models\Company company_id
|
||||
* @property string reference
|
||||
* @property string phone
|
||||
* @property string email
|
||||
* @property string wechat_id
|
||||
* @property int $country_id
|
||||
* @property int $company_id
|
||||
* @property string $reference
|
||||
* @property string $phone
|
||||
* @property string $email
|
||||
* @property string $wechat_id
|
||||
*/
|
||||
class Contact extends AbstractModel
|
||||
{
|
||||
@@ -23,20 +23,27 @@ class Contact extends AbstractModel
|
||||
|
||||
protected $table = 'contacts';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
**/
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function company(): HasOne
|
||||
{
|
||||
return $this->hasOne(Company::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return belongsTo
|
||||
* @return BelongsTo
|
||||
**/
|
||||
public function country(): belongsTo
|
||||
public function country(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Country::class);
|
||||
}
|
||||
|
||||
+14
-4
@@ -9,9 +9,9 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* Class Country
|
||||
* @package App\Models
|
||||
*
|
||||
* @property string name
|
||||
* @property string short_code
|
||||
* @property string phone_code
|
||||
* @property string $name
|
||||
* @property string $short_code
|
||||
* @property string $phone_code
|
||||
*/
|
||||
class Country extends AbstractModel
|
||||
{
|
||||
@@ -19,7 +19,17 @@ class Country extends AbstractModel
|
||||
|
||||
protected $table = 'countries';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
protected $fillable = ['name', 'short_code', 'phone_code'];
|
||||
|
||||
|
||||
+18
-8
@@ -6,16 +6,16 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\hasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* Class Currency
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Country country_id
|
||||
* @property string name
|
||||
* @property string short_code
|
||||
* @property string symbol
|
||||
* @property int $country_id
|
||||
* @property string $name
|
||||
* @property string $short_code
|
||||
* @property string $symbol
|
||||
*/
|
||||
|
||||
class Currency extends AbstractModel
|
||||
@@ -24,7 +24,17 @@ class Currency extends AbstractModel
|
||||
|
||||
protected $table = 'currencies';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
@@ -35,9 +45,9 @@ class Currency extends AbstractModel
|
||||
}
|
||||
|
||||
/**
|
||||
* @return hasMany
|
||||
* @return HasMany
|
||||
*/
|
||||
public function rates(): hasMany
|
||||
public function rates(): HasMany
|
||||
{
|
||||
return $this->hasMany(CurrencyRate::class, 'currency_id');
|
||||
}
|
||||
|
||||
@@ -12,5 +12,15 @@ class CurrencyRate extends AbstractModel
|
||||
|
||||
protected $fillable = ['currency_id', 'selling', 'payment_method_type'];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
+15
-5
@@ -10,10 +10,10 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* Class District
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Country country_id
|
||||
* @property \App\Models\State state_id
|
||||
* @property string name
|
||||
* @property string postcode
|
||||
* @property int $country_id
|
||||
* @property int $state_id
|
||||
* @property string $name
|
||||
* @property string $postcode
|
||||
*/
|
||||
class District extends AbstractModel
|
||||
{
|
||||
@@ -21,7 +21,17 @@ class District extends AbstractModel
|
||||
|
||||
protected $table = 'districts';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
|
||||
+24
-15
@@ -7,22 +7,21 @@ use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\hasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* Class Document
|
||||
* @package App\Models
|
||||
* @version August 4, 2020, 4:36 am
|
||||
*
|
||||
* @property int owner_id
|
||||
* @property int owner_type
|
||||
* @property int document_type
|
||||
* @property string reference
|
||||
* @property int status
|
||||
* @property \App\Models\User approver
|
||||
* @property timestamp issued_date
|
||||
* @property timestamp expired_date
|
||||
* @property timestamp approved_date
|
||||
* @property int $owner_id
|
||||
* @property int $owner_type
|
||||
* @property int $document_type
|
||||
* @property string $reference
|
||||
* @property int $status
|
||||
* @property int $approver
|
||||
* @property string $issued_date
|
||||
* @property string $expired_date
|
||||
* @property string $approved_date
|
||||
*/
|
||||
class Document extends AbstractModel
|
||||
{
|
||||
@@ -30,7 +29,17 @@ class Document extends AbstractModel
|
||||
|
||||
protected $table = 'documents';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
||||
@@ -41,9 +50,9 @@ class Document extends AbstractModel
|
||||
}
|
||||
|
||||
/**
|
||||
* @return hasMany
|
||||
* @return HasMany
|
||||
*/
|
||||
public function files(): hasMany
|
||||
public function files(): HasMany
|
||||
{
|
||||
return $this->hasMany(File::class, 'document_id');
|
||||
}
|
||||
@@ -51,7 +60,7 @@ class Document extends AbstractModel
|
||||
/**
|
||||
* @return HasOne
|
||||
*/
|
||||
public function approver(): hasOne
|
||||
public function approver(): HasOne
|
||||
{
|
||||
return $this->hasOne(User::class, 'id', 'approver');
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
/**
|
||||
* Class CompanyEmployee
|
||||
* Class Employee
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Company company_id
|
||||
* @property \App\Models\User user_id
|
||||
* @property int $company_id
|
||||
* @property int $user_id
|
||||
*/
|
||||
class Employee extends AbstractModel
|
||||
{
|
||||
@@ -24,9 +24,6 @@ class Employee extends AbstractModel
|
||||
return $this->HasMany(Company::class, 'company_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
**/
|
||||
public function user(): HasOne
|
||||
{
|
||||
return $this->hasOne(User::class, 'user_id', 'id');
|
||||
|
||||
+13
-8
@@ -8,11 +8,10 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
/**
|
||||
* Class File
|
||||
* @package App\Models
|
||||
* @version August 4, 2020, 4:36 am
|
||||
*
|
||||
* @property \App\Models\Document document_id
|
||||
* @property text file
|
||||
* @property int file_type_id
|
||||
* @property int $document_id
|
||||
* @property object $file
|
||||
* @property int $file_type_id
|
||||
*/
|
||||
class File extends AbstractModel
|
||||
{
|
||||
@@ -22,10 +21,16 @@ class File extends AbstractModel
|
||||
|
||||
protected $fillable = ['file'];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public function getFileAttribute($value)
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return $value ? json_decode($value) : [];
|
||||
return [
|
||||
'file' => 'object',
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@ class KeyValuePair extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected $table = 'key_value_pairs';
|
||||
|
||||
protected $fillable = [
|
||||
@@ -19,6 +17,18 @@ class KeyValuePair extends AbstractModel
|
||||
'value',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function owner(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
|
||||
@@ -8,7 +8,18 @@ class Milestone extends AbstractModel
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'milestones';
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function progress()
|
||||
{
|
||||
|
||||
@@ -9,7 +9,18 @@ class MilestoneProgress extends AbstractModel
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'milestone_progress';
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function milestone()
|
||||
{
|
||||
|
||||
@@ -15,9 +15,17 @@ class ModelAttribute extends Model
|
||||
"value"
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
"value" => "array"
|
||||
];
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
"value" => "array",
|
||||
];
|
||||
}
|
||||
|
||||
public function owner(): morphTo
|
||||
{
|
||||
|
||||
+12
-1
@@ -10,7 +10,18 @@ class Reward extends AbstractModel
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'rewards';
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function milestones()
|
||||
{
|
||||
|
||||
@@ -11,13 +11,13 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
* Class SeasonalSegment
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Company company_id
|
||||
* @property \App\Models\Bank transferable_bank_id
|
||||
* @property string marking
|
||||
* @property string reference
|
||||
* @property float fix_amount
|
||||
* @property int convertible_currency_id
|
||||
* @property int conversion_currency_id
|
||||
* @property int $company_id
|
||||
* @property int $transferable_bank_id
|
||||
* @property string $marking
|
||||
* @property string $reference
|
||||
* @property float $fix_amount
|
||||
* @property int $convertible_currency_id
|
||||
* @property int $conversion_currency_id
|
||||
*/
|
||||
class SeasonalSegment extends Model
|
||||
{
|
||||
@@ -27,11 +27,19 @@ class SeasonalSegment extends Model
|
||||
|
||||
protected $table = 'seasonal_segment';
|
||||
|
||||
protected $dates = [
|
||||
'starting_on',
|
||||
'ending_on',
|
||||
'deleted_at',
|
||||
];
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'starting_on' => 'datetime',
|
||||
'ending_on' => 'datetime',
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
|
||||
+13
-3
@@ -9,8 +9,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* Class Segment
|
||||
* @package App\Models
|
||||
*
|
||||
* @property string name
|
||||
* @property string reference
|
||||
* @property string $name
|
||||
* @property string $reference
|
||||
*/
|
||||
class Segment extends AbstractModel
|
||||
{
|
||||
@@ -18,7 +18,17 @@ class Segment extends AbstractModel
|
||||
|
||||
protected $table = 'segments';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
|
||||
@@ -10,8 +10,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* Class SegmentConstant
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Segment segment_id
|
||||
* @property string detail
|
||||
* @property int $segment_id
|
||||
* @property object $detail
|
||||
*/
|
||||
class SegmentConstant extends AbstractModel
|
||||
{
|
||||
@@ -19,15 +19,17 @@ class SegmentConstant extends AbstractModel
|
||||
|
||||
protected $table = 'segment_constants';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
// protected $casts = [
|
||||
// 'detail' => 'array',
|
||||
// ];
|
||||
|
||||
public function getDetailAttribute($value)
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return $value ? json_decode($value) : [];
|
||||
return [
|
||||
'detail' => 'object',
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+15
-15
@@ -13,7 +13,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @package App\Models
|
||||
* @version February 16, 2021, 9:04 pm
|
||||
*
|
||||
* @property string name
|
||||
* @property string $name
|
||||
*/
|
||||
class ServiceType extends AbstractModel
|
||||
{
|
||||
@@ -23,46 +23,46 @@ class ServiceType extends AbstractModel
|
||||
|
||||
protected $table = 'service_types';
|
||||
|
||||
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
|
||||
|
||||
public $fillable = [
|
||||
'name'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'name' => 'string'
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'string',
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation rules
|
||||
*
|
||||
* @var array
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public static $rules = [
|
||||
'name' => 'required'
|
||||
];
|
||||
|
||||
/**
|
||||
* @return hasMany
|
||||
* @return HasMany
|
||||
*/
|
||||
public function rates(): hasMany
|
||||
public function rates(): HasMany
|
||||
{
|
||||
return $this->hasMany(CurrencyRate::class, 'service_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return hasMany
|
||||
* @return HasMany
|
||||
*/
|
||||
public function constants(): hasMany
|
||||
public function constants(): HasMany
|
||||
{
|
||||
return $this->hasMany(SegmentConstant::class, 'detail->id')
|
||||
->whereIn('reference', [SegmentConstants::SERVICE_TYPE, SegmentConstants::CUSTOM_SERVICE_TYPE]);
|
||||
|
||||
+13
-3
@@ -9,8 +9,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* Class State
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Country country_id
|
||||
* @property string name
|
||||
* @property int $country_id
|
||||
* @property string $name
|
||||
*/
|
||||
class State extends AbstractModel
|
||||
{
|
||||
@@ -18,7 +18,17 @@ class State extends AbstractModel
|
||||
|
||||
protected $table = 'states';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasOne
|
||||
|
||||
@@ -30,9 +30,17 @@ class StatementTransaction extends Model
|
||||
'end_balance',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'posting_date' => 'datetime',
|
||||
];
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'posting_date' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function account()
|
||||
{
|
||||
|
||||
@@ -29,12 +29,20 @@ class Transaction extends AbstractModel implements Documentable, Transactionable
|
||||
use SoftDeletes;
|
||||
use LogData;
|
||||
|
||||
protected $casts = [
|
||||
'type' => 'int'
|
||||
];
|
||||
|
||||
protected $table = 'transactions';
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'int',
|
||||
];
|
||||
}
|
||||
|
||||
public function owner(): morphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
|
||||
@@ -9,9 +9,17 @@ class TransactionMappingLog extends Model
|
||||
{
|
||||
protected $fillable = ['imported_by','data','imported_date','type'];
|
||||
|
||||
protected $casts = [
|
||||
'data' => 'array',
|
||||
];
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'data' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public static function boot() {
|
||||
parent::boot();
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ class User extends AbstractModel implements
|
||||
return $this->HasMany(UserReward::class, 'user_id', 'id');
|
||||
}
|
||||
|
||||
public function hasAttribute(string $key, $value = null): bool
|
||||
public function hasCustomAttribute(string $key, $value = null): bool
|
||||
{
|
||||
$query = $this->attributesKVP()->where('key', $key);
|
||||
|
||||
|
||||
@@ -15,10 +15,18 @@ class UserAffiliate extends AbstractModel
|
||||
'registered_at'
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'clicked_at',
|
||||
'registered_at'
|
||||
];
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'clicked_at' => 'datetime',
|
||||
'registered_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
|
||||
@@ -9,7 +9,18 @@ class UserReward extends AbstractModel
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'user_rewards';
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function reward()
|
||||
{
|
||||
|
||||
@@ -10,7 +10,18 @@ class VoucherEntityMapping extends AbstractModel
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'voucher_entity_mappings';
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
||||
|
||||
@@ -4,6 +4,9 @@ namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
@@ -27,5 +30,10 @@ class AppServiceProvider extends ServiceProvider
|
||||
if (!file_exists(storage_path('framework/sessions'))) {
|
||||
mkdir(storage_path('framework/sessions'), 0777, true);
|
||||
}
|
||||
|
||||
//From Shipping Portal
|
||||
// RateLimiter::for('api', function (Request $request) {
|
||||
// return Limit::perMinute(300)->by($request->user()?->id ?: $request->ip());
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@ class AuthServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* This namespace is applied to your controller routes.
|
||||
*
|
||||
* In addition, it is set as the URL generator's root namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'App\Http\Controllers';
|
||||
|
||||
/**
|
||||
* The path to the "home" route for your application.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/home';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
|
||||
$this->mapApiPubRoutes();
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapWebRoutes()
|
||||
{
|
||||
Route::middleware('web')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "apipub" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapApiPubRoutes()
|
||||
{
|
||||
Route::prefix('public/api')
|
||||
->middleware('apipub')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/apipub.php'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user