Dashboard and Reports

This module allows you to add multiple Report Widgets to your Dashboard. There are five types of Widgets, each with its own parameters.

You can create as many widgets as you want, specifying width for each of them, this way constructing your whole dashboard.

Video demo of the module:

In downloaded code, we generate HomeController.php which may look like this:

use LaravelDaily\LaravelCharts\Classes\LaravelChart;

class HomeController
{
    public function index()
    {
        $settings1 = [
            'chart_title'        => 'Users By Day',
            'chart_type'         => 'line',
            'report_type'        => 'group_by_date',
            'model'              => 'App\User',
            'group_by_field'     => 'created_at',
            'group_by_period'    => 'day',
            'aggregate_function' => 'count',
            'filter_field'       => 'created_at',
            'filter_days'        => '30',
            'column_class'       => 'col-md-12',
            'entries_number'     => '5',
        ];

        $chart1 = new LaravelChart($settings1);

        $settings2 = [
            'chart_title'        => 'Latest Users',
            'chart_type'         => 'latest_entries',
            'report_type'        => 'group_by_date',
            'model'              => 'App\User',
            'group_by_field'     => 'email_verified_at',
            'group_by_period'    => 'day',
            'aggregate_function' => 'count',
            'filter_field'       => 'created_at',
            'column_class'       => 'col-md-12',
            'entries_number'     => '5',
            'fields'             => [
                '0' => 'name',
                '1' => 'email',
                '2' => 'created_at',
            ],
        ];

        $settings2['data'] = $settings2['model']::latest()
            ->take($settings2['entries_number'])
            ->get();

        return view('home', compact('chart1', 'settings2'));
    }
}

You can also group entries by relationships, see video:

For viewing charts, we use our own simple package called Laravel Charts.

Last updated