1. Go to this page and download the library: Download fireworkweb/laravel-gates 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/ */
namespace App\Policies;
use App\Post;
use App\User;
use Fireworkweb\Gates\Traits\HasGates;
class PolicyWithResourceGates
{
use HasGates;
protected static function gateRouteName() : string
{
return 'posts';
}
protected static function gateAbilities() : array
{
return [
'edit' => 'edit',
];
}
public function edit(User $user, Post $post)
{
return $user->id === $post->user_id;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.