KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Accessing logined user information from Dashboard or widget. #2334

Open Javier Gallardo opened this topic on on Sep 10 - 3 comments

Javier Gallardo commented on Sep 10
<?php

namespace space;

use \koolreport\dashboard\widgets\Table;

class GraphicTable extends Table
{
    protected function dataSource()
    {
        return
//Code Koolreport .dev
        $user = $this->App()->User();
        $username = $user->name();
        $id = $user->id();
        $roles  = $user->roles();
        echo  $roles;
    }
}
Javier Gallardo commented on Sep 10

Javier Gallardo commented on Sep 16

????????????????????????????????

KoolReport commented 6 days ago

Here is an sample code (not real) but demonstrate how to access logged in user id and make query to get list orders for an user. The orders of that users will be displayed in a table.

namespace space;

use \koolreport\dashboard\widgets\Table;

class GraphicTable extends Table
{

    protected function dataSource()
    {
        $user = $this->app()->user();
        $username = $user->name();
        $id = $user->id();
        $roles  = $user->roles();

        return AutoMaker::table("orders")->where("user_id",$id);
    }
}

Hope that helps.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None