KoolReport's Forum

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

How to display logged in user data outside of App.php MYSQL #2326

Closed Javier Gallardo opened this topic on on Sep 7, 2021 - 14 comments

Javier Gallardo commented on Sep 7, 2021

how to display logged in user data outside of App.php MYSQL

KoolReport commented on Sep 8, 2021

Although I have not fully understood your question but I guess you are asking about accessing logined user information from Dashboard or widget. In any where, you always can access user information with:

$user = $this->app()->user();
$username = $user->name();
$id = $user->id();
$roles  = $user->roles();
Javier Gallardo commented on Sep 10, 2021

I need create a method? do you havean example in more detail?

Javier Gallardo commented on Sep 10, 2021

Message: Using $this when not in object context Line: 16

I have this message

KoolReport commented on Sep 10, 2021

Can you have more detail of the message. Please give us the screenshoot

Javier Gallardo commented on Sep 10, 2021

<?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
}

}

KoolReport commented on Sep 10, 2021
<?php

namespace space;

use \koolreport\dashboard\widgets\Table;

class GraphicTable extends Table
{
    protected function dataSource()
    {
        return ConnectDB::table("users")
                ->select("username");
        //---> Because of return in above line, the code below never run <--
        //Code Koolreport .dev
        $user = $this->App()->User(); // --> it should be $this->app()->user()
        $username = $user->name();
        $id = $user->id();
        $roles  = $user->roles();

    }
}
Javier Gallardo commented on Sep 10, 2021

Javier Gallardo commented on Sep 10, 2021
<?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, 2021

I forgot to remove that part this is that I use

Javier Gallardo commented on Sep 10, 2021

KoolReport commented on Sep 10, 2021

The dataSource() need us to return a query or a datasource, now you return nothing so you have this error.

Javier Gallardo commented on Sep 16, 2021

what should I do? I need help

Javier Gallardo commented on Sep 17, 2021

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

KoolReport commented on Sep 17, 2021

I have answered you in another post.

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