mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
72 lines
1.3 KiB
PHP
72 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
|
use App\Models\AbstractModel as Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
/**
|
|
* Class ServiceType
|
|
* @package App\Models
|
|
* @version February 16, 2021, 9:04 pm
|
|
*
|
|
* @property string $name
|
|
*/
|
|
class ServiceType extends AbstractModel
|
|
{
|
|
|
|
use SoftDeletes;
|
|
|
|
|
|
protected $table = 'service_types';
|
|
|
|
|
|
|
|
public $fillable = [
|
|
'name'
|
|
];
|
|
|
|
/**
|
|
* Get the attributes that should be cast.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'name' => 'string',
|
|
'deleted_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Validation rules
|
|
*
|
|
* @var array<string, string>
|
|
*/
|
|
public static $rules = [
|
|
'name' => 'required'
|
|
];
|
|
|
|
/**
|
|
* @return HasMany
|
|
*/
|
|
public function rates(): HasMany
|
|
{
|
|
return $this->hasMany(CurrencyRate::class, 'service_id');
|
|
}
|
|
|
|
/**
|
|
* @return HasMany
|
|
*/
|
|
public function constants(): HasMany
|
|
{
|
|
return $this->hasMany(SegmentConstant::class, 'detail->id')
|
|
->whereIn('reference', [SegmentConstants::SERVICE_TYPE, SegmentConstants::CUSTOM_SERVICE_TYPE]);
|
|
}
|
|
|
|
}
|