mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
new: Add models currency, passwordReset, segmentCompany, segmentConstant. #1
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
class Currency extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'currencies';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function country(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(Country::class, 'country_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return hasMany
|
||||
*/
|
||||
public function rates(): hasMany
|
||||
{
|
||||
return $this->hasMany(CurrencyRate::class, 'currency_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class PasswordReset extends AbstractModel
|
||||
{
|
||||
protected $table = 'password_resets';
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeActive($query){
|
||||
return $query->where('is_expired', false)->where('is_complete', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo {
|
||||
return $this->belongsTo(User::class, 'user_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class SegmentCompany extends AbstractModel
|
||||
{
|
||||
protected $table = 'segment_companies';
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class SegmentConstant
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Segment segment_id
|
||||
* @property string detail
|
||||
*/
|
||||
class SegmentConstant extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'segment_constants';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public function getDetailAttribute($value)
|
||||
{
|
||||
return $value ? json_decode($value) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function segment(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(Segment::class, 'segment_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function service(){
|
||||
return $this->hasOne(ServiceType::class, 'id', 'detail->id')
|
||||
->whereIn('reference', [SegmentConstants::SERVICE_TYPE, SegmentConstants::CUSTOM_SERVICE_TYPE]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user