Files
ProxyPanel/app/Models/RuleGroup.php
兔姬桑 f25f2aea62 优化数据库 与 简化控制器 & more
1. 继续修改表表关系,与关联字段的限制;
2. 通过表表关系,简化一部分代码,自动让Laravel建立关联;
3. 拆分验证 与 优化数据创建与修改的获取数据操作;
4. 修改部分无意义的数据名称;
2020-12-28 12:09:20 +08:00

31 lines
610 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* 审计规则分组.
*/
class RuleGroup extends Model
{
protected $table = 'rule_group';
protected $guarded = [];
public function getTypeLabelAttribute(): string
{
if ($this->attributes['type']) {
$type_label = '<span class="badge badge-danger">阻 断</span>';
} else {
$type_label = '<span class="badge badge-primary">放 行</span>';
}
return $type_label;
}
public function rules()
{
return $this->belongsToMany(Rule::class);
}
}