Update: laravel 8 to 12, php 7.3 to php 8.3, Jenkinsfile, Unit/Feature testing, vapor, docker

This commit is contained in:
Dillon Ngo
2026-04-03 06:59:39 +08:00
parent 58de1017d7
commit b34b7c19d6
142 changed files with 3334 additions and 1101 deletions
+11 -2
View File
@@ -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');
}
}
}
+12 -4
View File
@@ -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
View File
@@ -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();
}
}
+15 -7
View File
@@ -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
-4
View File
@@ -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
View File
@@ -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',
+11 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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');
}
+11 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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');
}
+3 -6
View File
@@ -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
View File
@@ -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',
];
}
}
+12 -2
View File
@@ -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();
+12 -1
View File
@@ -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()
{
+12 -1
View File
@@ -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()
{
+11 -3
View File
@@ -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
View File
@@ -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()
{
+20 -12
View File
@@ -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
View File
@@ -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
+12 -10
View File
@@ -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
View File
@@ -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
View File
@@ -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
+11 -3
View File
@@ -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()
{
+12 -4
View File
@@ -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();
+11 -3
View File
@@ -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
View File
@@ -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);
+12 -4
View File
@@ -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
+12 -1
View File
@@ -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()
{
+12 -1
View File
@@ -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