samedi 22 août 2015

streamline passing user variable to controller laravel

I'm using $user = Auth::user(); in every method of my Projects controller.

I use it to get projects that belongs to user, and also pass to views.

How would I streamline that?

for example:

public function index()
    {
        $user     = Auth::user();
        $projects = $user->projects;
        return view('project.index', compact('user', 'projects'));
    }

I thought about using view composer but I still need $user inside controller for getting data...



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

Aucun commentaire:

Enregistrer un commentaire