Answers for "spatie/laravel-permission laravel 7"

PHP
2

laravel file permissions

sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
Posted by: Guest on September-09-2020
0

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
Posted by: Guest on March-30-2021
0

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"
Posted by: Guest on December-17-2020
0

Laravel permission

protected $routeMiddleware = [
    // ...
    'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
    'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
    'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
];
Posted by: Guest on July-19-2021
-2

laravel spatie roles and permissions tutorial

cd ~/Sites
laravel new mypermissionsdemo
cd mypermissionsdemo
git init
git add .
git commit -m "Fresh Laravel Install"

# Environment
cp -n .env.example .env
sed -i '' 's/DB_CONNECTION=mysql/DB_CONNECTION=sqlite/' .env
sed -i '' 's/DB_DATABASE=/#DB_DATABASE=/' .env
touch database/database.sqlite

# Package
composer require spatie/laravel-permission
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
git add .
git commit -m "Add Spatie Laravel Permissions package"
php artisan migrate:fresh

# Add `HasRoles` trait to User model
sed -i '' $'s/use Notifiable;/use Notifiable;\\\n    use \\\\Spatie\\\\Permission\\\\Traits\\\\HasRoles;/' app/User.php
sed -i '' $'s/use HasFactory, Notifiable;/use HasFactory, Notifiable;\\\n    use \\\\Spatie\\\\Permission\\\\Traits\\\\HasRoles;/' app/Models/User.php
git add . && git commit -m "Add HasRoles trait"

# Add Laravel's basic auth scaffolding
composer require laravel/ui --dev
php artisan ui bootstrap --auth
# npm install && npm run prod
git add . && git commit -m "Setup auth scaffold"
Posted by: Guest on January-29-2021

Code answers related to "spatie/laravel-permission laravel 7"

Browse Popular Code Answers by Language