love_php/app/Models/SaasUserAppointment.php
2026-04-02 09:20:51 +08:00

48 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use App\Models\Live\Anchor;
use App\Models\Server\MerchantUser;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;
class SaasUserAppointment extends Base
{
protected $fillable = [];
protected $guarded = [];
public function merchant_user()
{
return $this->belongsTo(MerchantUser::class, 'merchant_user_id', 'id');
}
public function merchant(){
return $this->belongsTo(MerchantAccount::class,'merchant_id','id');
}
public function anchor() {
return $this->belongsTo(Anchor::class, 'merchant_id', 'm_id');
}
public function getStartTimeAttribute()
{
if ($this->attributes['start_time']) {
return Carbon::parse($this->attributes['start_time'])->format('H:i');
}
}
public function getEndTimeAttribute()
{
if ($this->attributes['end_time']) {
$time = Carbon::parse($this->attributes['end_time'])->format('H:i');
if($time == '00:00'){
$time = '24:00';
}
return $time;
}
}
}