mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
54 lines
1.1 KiB
PHP
54 lines
1.1 KiB
PHP
<?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 int $segment_id
|
|
* @property object $detail
|
|
*/
|
|
class SegmentConstant extends AbstractModel
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'segment_constants';
|
|
|
|
/**
|
|
* Get the attributes that should be cast.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'detail' => 'object',
|
|
'deleted_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @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]);
|
|
}
|
|
|
|
|
|
|
|
}
|