add: copy serviceType models file from exchange2.0.

This commit is contained in:
weichien00
2021-07-08 01:10:49 +08:00
parent 99b173c4c8
commit 644339a224
+70
View File
@@ -0,0 +1,70 @@
<?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';
protected $dates = ['deleted_at'];
public $fillable = [
'name'
];
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts = [
'name' => 'string'
];
/**
* Validation rules
*
* @var array
*/
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]);
}
}