KTV/app/Models/Branch.php

39 lines
917 B
PHP
Raw Normal View History

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
2025-05-12 14:13:56 +08:00
use App\Traits\LogsModelActivity;
class Branch extends Model
{
/** @use HasFactory<\Database\Factories\ArtistFactory> */
2025-05-12 14:13:56 +08:00
use HasFactory, LogsModelActivity;
protected $fillable = [
'name',
'external_ip',
2025-05-12 14:13:56 +08:00
'enable',
];
2025-06-04 14:56:08 +08:00
protected $casts = [
'name' => 'string',
'external_ip'=> 'string',
'enable' => 'boolean',
];
public function rooms() {
return $this->hasMany(Room::class);
}
public function songs(){
return $this->belongsToMany(Song::class)
->withPivot('counts')
->withTimestamps();
}
2025-05-14 15:32:54 +08:00
protected static function booted()
{
static::deleting(function (Branch $branch) {
$branch->rooms()->delete();
});
}
}