No one?
Oct 9, 2015
10
Level 6
Policy on create
With the code below i will check if a user has the rights to create a new post object, but even when I return TRUE the link will not show up. What am I doing wrong?
view:
@can('create-post')
<a>new post</a>
@endcan
PostPolicy.php
<?php
namespace App\Policies;
class PostPolicy
{
public function create()
{
return TRUE;
}
}
AuthServiceProvider:
<?php
namespace App\Providers;
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
Post::class => PostPolicy::class,
];
/**
* Register any application authentication / authorization services.
*
* @param \Illuminate\Contracts\Auth\Access\Gate $gate
* @return void
*/
public function boot(GateContract $gate)
{
parent::registerPolicies($gate);
}
}
````
Please or to participate in this conversation.