controller - Laravel Middleware access protected values -


i wrote own user-role system, dont know how implement verification in middleware routes.

the middleware class calling on every request.

i recive $request->user() can not access attributes verify if user has correct permissions.

my middleware controller looks this:

namespace app\http\middleware;  use closure; use activation; use cartalyst\sentinel\laravel\facades\sentinel;  class accountmiddleware {     /**      * handle incoming request.      *      * @param  \illuminate\http\request  $request      * @param  \closure  $next      * @return mixed      */     public function handle($request, closure $next)     {         $user = sentinel::findbycredentials([             'login' => $request->user()->attributes['email']         );         ...         return $next($request);     } } 

it doesnt work.

if trie dump $request->user() can see properties there protected. need change, make work?

accessing eloquent model properties done via accessors, in case via __get magic method. don't need access them through $attributes property array, need this:

$request->user()->email; 

the above return user email because illuminate\database\eloquent\model::__get method fetches specified attribute automatically.


if like, can define own accessors or mutators modify attribute values when reading or writing them database.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -