public function field() { return $this->belongsTo(HrmAuthFieldsModel::class, 'filed_id', 'id'); } public function children() { return $this->hasMany(HrmAuthFuncFieldsModel::class, 'father_id'); } public function getIsEmptyAttribute() { if (count($this->children) > 0) { return false; } return true; } public function scopeValid($query) { $query->where('hrm_auth_func_fields.status', self::STATUS_VALID); }
1. 根据属性获取方法
2. getIsEmptyAttirbute()
3. scopeValid()