User 介面 只能看資料不能做修改 Role 介面移除 Branch介面 只能看資料不能做修改 Room 介面 可操控 包廂開關台 Sqgger API 可操控API Room 有操控異動記錄 machine_statuses 需做資料留存需留7 天 20250528
35 lines
793 B
PHP
35 lines
793 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use App\Traits\LogsModelActivity;
|
|
|
|
class Branch extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\ArtistFactory> */
|
|
use HasFactory, LogsModelActivity;
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'external_ip',
|
|
'enable',
|
|
];
|
|
|
|
public function rooms() {
|
|
return $this->hasMany(Room::class);
|
|
}
|
|
public function songs(){
|
|
return $this->belongsToMany(Song::class)
|
|
->withPivot('counts')
|
|
->withTimestamps();
|
|
}
|
|
protected static function booted()
|
|
{
|
|
static::deleting(function (Branch $branch) {
|
|
$branch->rooms()->delete();
|
|
});
|
|
}
|
|
}
|