lundi 6 février 2017

Laravel policy always false

I'm trying to allow user to view their own profile in Laravel 5.4.

UserPolicy.php

public function view(User $user, $subject)
{ 
 return true;
}

registered policy in AuthServiceProvider.php

protected $policies = [
    App\Task::class => App\Policies\TaskPolicy::class,
    App\User::class => App\Policies\UserPolicy::class
];

Routes

Route::group(['middleware' => 'auth'], function() {
  Route::resource('user', 'UserController');
} );

Blade template

@can ( 'view', $user )
// yes
@else
// no
@endcan

The return is always 'false'. Same for calling policy form the controller. Where do I go wrong?



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

Aucun commentaire:

Enregistrer un commentaire