fuc-new/src/Models/Ann.php
hellcat 1fe8673f62 1
2025-10-01 13:34:29 +08:00

34 lines
819 B
PHP
Executable File

<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Query\Builder;
/**
* @property int $id 公告ID
* @property string $date 公告日期
* @property string $content 公告内容
*
* @mixin Builder
*/
final class Ann extends Model
{
protected $connection = 'default';
protected $table = 'announcement';
public function setRankAttribute($value)
{
$allowedStatuses = ['none', 'warning', 'danger', 'success'];
if (! in_array($value, $allowedStatuses)) {
throw new \InvalidArgumentException(
"无效的用户状态。允许的状态有: " . implode(', ', $allowedStatuses) . ". 传入值: " . $value
);
} else {
$this->attributes['rank'] = $value;
}
}
}