generated from liutk/owl-admin-base
添加withcount
parent
86469f0f83
commit
894bcaa534
|
|
@ -46,7 +46,7 @@ class ActivityController extends AdminController
|
|||
"2"=>"<span class='label label-success'>已结束</span>",
|
||||
"*"=> '其他:${gender}'
|
||||
]),
|
||||
amis()->TableColumn('user_count', __('admin.activities.user_count')),
|
||||
amis()->TableColumn('logs_count', __('admin.activities.user_count')),
|
||||
amis()->TableColumn('start_at', __('admin.activities.start_at')),
|
||||
amis()->TableColumn('end_at', __('admin.activities.end_at')),
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ class ActivityService extends BaseService
|
|||
|
||||
protected bool $modelSortAble = true;
|
||||
|
||||
protected array $withRelationshipsCount = ['logs'];
|
||||
|
||||
public function store($data): bool
|
||||
{
|
||||
$columns = $this->getTableColumns();
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ use Slowlyo\OwlAdmin\Services\AdminService;
|
|||
*/
|
||||
class BaseService extends AdminService
|
||||
{
|
||||
protected array $withRelationshipsCount = [];
|
||||
|
||||
protected array $withRelationships = [];
|
||||
|
||||
protected string $modelFilterName = '';
|
||||
|
|
@ -38,6 +40,10 @@ class BaseService extends AdminService
|
|||
$query->with($this->withRelationships);
|
||||
}
|
||||
|
||||
if($this->withRelationshipsCount){
|
||||
$query->withCount($this->withRelationshipsCount);
|
||||
}
|
||||
|
||||
if ($filter) {
|
||||
$query->filter(request()->input(), $filter);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue