68 lines
1.6 KiB
PHP
68 lines
1.6 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Models;
|
||
|
|
||
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
||
|
class SongLibraryCache extends Model
|
||
|
{
|
||
|
protected $table = 'song_library_cache';
|
||
|
protected $primaryKey = 'song_id';
|
||
|
public $incrementing = true;
|
||
|
protected $keyType = 'int';
|
||
|
const CREATED_AT = null;
|
||
|
const UPDATED_AT = 'updated_at';
|
||
|
|
||
|
// 可寫入的欄位(可依需要擴充)
|
||
|
protected $fillable = [
|
||
|
'song_name',
|
||
|
'song_simplified',
|
||
|
'phonetic_abbr',
|
||
|
'pinyin_abbr',
|
||
|
'strokes_abbr',
|
||
|
'song_number',
|
||
|
'artistA',
|
||
|
'artistB',
|
||
|
'artistA_simplified',
|
||
|
'artistB_simplified',
|
||
|
'artistA_category',
|
||
|
'artistB_category',
|
||
|
'artist_category',
|
||
|
'song_filename',
|
||
|
'song_category',
|
||
|
'language_name',
|
||
|
'add_date',
|
||
|
'situation',
|
||
|
'vocal',
|
||
|
'db_change',
|
||
|
'song_counts',
|
||
|
'updated_at',
|
||
|
];
|
||
|
public function save(array $options = [])
|
||
|
{
|
||
|
throw new \Exception("SongLibraryCache is read-only.");
|
||
|
}
|
||
|
|
||
|
public function delete()
|
||
|
{
|
||
|
throw new \Exception("SongLibraryCache cannot be deleted.");
|
||
|
}
|
||
|
|
||
|
public static function create(array $attributes = [])
|
||
|
{
|
||
|
throw new \Exception("SongLibraryCache is read-only.");
|
||
|
}
|
||
|
|
||
|
public static function booted()
|
||
|
{
|
||
|
// 防止 mass update/delete
|
||
|
static::updating(function () {
|
||
|
throw new \Exception("Updating is not allowed.");
|
||
|
});
|
||
|
|
||
|
static::deleting(function () {
|
||
|
throw new \Exception("Deleting is not allowed.");
|
||
|
});
|
||
|
}
|
||
|
}
|