Adminix Documentation Help

Counter

image.png
image.png

Description

This module displays count of some entity in database, selected according to the necessary criteria. For example, you can display total number of registered users or, today orders, or something else.

Configuration

use App\Models\User; use AlexKudrya\Adminix\AdminixPage; use AlexKudrya\Adminix\Modules\Counter\CounterModule; use Carbon\Carbon; ... $page = new AdminixPage(); ... $page->addModules( CounterModule::title('TOTAL USERS') ->name('total_users') ->icon('bi bi-people') ->dataSource(\App\Models\User::class) ->criteria([ ['is_admin', false], ]), CounterModule::title('TODAY REGISTRATIONS') ->name('today_registrations') ->icon('bi bi-person-add') ->dataSource(\App\Models\User::class) ->criteria([ ['is_admin', false], ['created_at', '>=', Carbon::today()->startOfDay()->toDateTimeString()] ]) ); ...

To add to the page Counter module you need paste AlexKudrya\Adminix\Modules\Counter\CounterModule class instance as an argument to addModule or addModules method of AdminixPage object.

CounterModule configuration

Method

Description

title

Title on top of the counter

title('TOTAL USERS')

Required

name

Name of module, must be unique in current page.

name('total_users')

Required

icon

Icon class name from Bootsrap icons

Example: to generate in right side of the Counter an icon <i class="bi bi-people"></i> you need paste here bi bi-people class name

icon('bi bi-people')

Optional

dataSource

Source of data for Counter, can be an Eloquent Model - \App\Models\User::class or name of table in database users or public.users

dataSource(\App\Models\User::class)

Required

criteria

Database Builder criteria to render records. For example to not show administrator you need paste this:

criteria([ ['is_admin', '=', false] ])

Or you can paste parameter from route:

criteria([ ['user_id', '=', 'param:1'] ])

For example, for https://site.com/adminix/comments/21 it wiil be mean that you need all comments where user_id == 21.

Optional

Last modified: 04 June 2024