1. Go to this page and download the library: Download nahid/permit library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$user = User::find(1);
if (Permit::userCan($user, 'post.create')) {
//do something
}
$user = User::find(1);
if (Permit::roleCan($user, 'post.create')) {
//do something
}
$user = User::find(1);
if (Permit::can($user, 'post.create')) {
//do something
}
namespace App\Policies;
use App\Comment;
use App\User;
class CommentPolicy
{
public function update(User $user, Comment $comment)
{
return $user->id == $comment->user_id;
}
}