spatie laravel permission laravel version 8 code example

Example 1: laravel permission

//install laravel permission with composer installer for Laravel 6.0 or higher
composer require spatie/laravel-permission
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"

Example 2: spatie/laravel-permission

// Install package
composer require spatie/laravel-permission

// config/app.php
'providers' => [
    // ...
    Spatie\Permission\PermissionServiceProvider::class,
];

// Publish config file
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"

// Clear cache
php artisan optimize:clear
 # or
php artisan config:clear

// Run migration to create tables
php artisan migrate

Tags:

Php Example