mardi 29 décembre 2015

Error in defining Multi Auth variable in constructor in laravel

When I define user name in constructor then In composer when I run route:list Command then I find error

Code:

public function __construct()

{
    $this->data = [];
    $this->data['pageTitle'] = 'Category';
    $this->data['username'] =  Auth::admin()->get()->email;
    $this->data['categories'] = Category::all();
}

Error :

http://ift.tt/22xTvot

But When I define username in functions like in index or show function then it work properly but I want to define this 'Auth' variable in constructor so that I can use this variable in whole controller's function so that I don't have any need to define in different different function .

Code:

Here

public function __construct() {

    $this->data = [];
    $this->data['pageTitle'] = 'Category';
    $this->data['categories'] = Category::all();
}

/**
 * Display a listing of the resource.
 *
 * @return Response
 */
public function index()
{
    $this->data['username'] =  Auth::admin()->get()->email;
    return view('admin.category.index',$this->data);

}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/22xTvEU
via IFTTT

Aucun commentaire:

Enregistrer un commentaire