This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Illuminate\Support\Facades\Gate; | |
Gate::guessPolicyNamesUsing(function (string $modelClass) { | |
// Provide the name of the model’s policy class… | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use App\Models\Post; | |
use App\Policies\PostPolicy; | |
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use App\Policies\PostPolicy; | |
use Illuminate\Support\Facades\Gate; | |
/** | |
* Register all authorization and authentication services. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use App\Models\Post; | |
use App\Models\User; | |
use Illuminate\Support\Facades\Gate; | |
/** | |
* Register all authorization and authentication services. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostPolicy | |
{ | |
public function update(User $user) | |
{ | |
return $ $user->role == ‘admin’; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gate::define('can_post', function($user) { | |
return $user->role == 'admin'; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#.dockerignore | |
.idea/ | |
.git/ | |
/node_modules | |
/.next/ | |
/out/ | |
/build |
NewerOlder