Files
exchange-2.0/app/Models/ServiceType.php
T
omair saleh 05401f6bbc large commit
2021-03-11 13:06:40 +08:00

72 lines
1.2 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';
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]);
}
}