amdp3-metaforums/Application/Models/Category.php

24 lines
670 B
PHP
Raw Permalink Normal View History

2019-11-19 03:36:39 +00:00
<?php
namespace Application\Models;
use Application\Foundations\Model as DBModel;
2019-11-20 05:19:02 +00:00
use Application\Foundations\QueryBuilder;
2019-11-19 03:36:39 +00:00
class Category extends DBModel {
2019-11-20 05:19:02 +00:00
public function moderators_attribute() {
$query = new QueryBuilder();
$query = $query->where('category_id',$this->id);
$moderators = ModeratorCategory::select($query);
if(count($moderators) == 0) return [];
$moderators = array_map(function($a) {
return $a->user_id;
}, $moderators);
$query = new QueryBuilder();
$query = $query->whereIn('id',$moderators);
return User::select($query);
}
public function group() {
return Group::find($this->group_id);
}
2019-11-19 03:36:39 +00:00
}