- Login
- Logout
- Permission
- Role
- Profile
- PHP 8.0
- Laravel 9
- Spatie Laravel permission
- Laravel Sanctum
- Cviebrock Sluggable
There are two methods you can install this package inside your laravel application.
- First you need to download
1.0.9branch in your local machine. - Then make
modulesfolder in root of your laravel project. - Inside
modulesfolder create another folder calledacl - Then paste all folders from your downloaded folder to
modules/acl
"repositories": [
{
"type": "path",
"url": "modules/acl",
"options": {
"symlink": true
}
}
],composer require modules/acl:dev-mainSpatie\Permission\PermissionServiceProvider::class,
Modules\Acl\Providers\AclServiceProvider::class,composer dump-autoloadphp artisan vendor:publishSpatie Permission publish must be before ACL publish
Choose --provider="Spatie\Permission\PermissionServiceProvider"
Then you need to publish acl-config tag
This will create configuration file to this config/acl.php path. You can modify some configuration here. If you don't want to change anything you can skip this tag publishing step.
Choose --provider="Modules\Acl\Providers\AclServiceProvider"
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
'api.json' => \Modules\Acl\Http\Middleware\JsonMiddleware::class,
'verify.token' => \Modules\Acl\Http\Middleware\TokenValidationMiddleware::class,$this->call(AclDatabaseSeeder::class);create_user_profile_table.php this is our default profile table. You are free to delete this if profile already exists
use Spatie\Permission\Traits\HasRoles;
use Modules\Acl\Traits\SoftDeletes;use HasRoles, SoftDeletes;Add deleted_by in your User Models $fillable array AND email_verified_at in your $hidden array. Then add this in your User Model
protected static function boot()
{
parent::boot();
static::restoring(function ($model) {
$model->deleted_by = null;
});
}php artisan migrate:fresh --seedphp artisan migrate
php artisan db:seed --class=AclDatabaseSeederIf using Docker on MAC OS, need to use '${VITE_PORT:-5173}:${VITE_PORT:-5173}' Port number can be changed. Example:
app:
build:
args:
user: www
uid: 1000
context: ./
dockerfile: Dockerfile
image: laravel-image
container_name: laravel-app
ports:
- '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
restart: unless-stopped
working_dir: /var/www/
depends_on:
- mysql========================================================================================================================================================
inside url you need to give your git username:apppassword
"repositories":[
{
"type": "vcs",
"url": "https://username:apppassword@bitbucket.org/your-repo/your-project.git"
}
],composer require modules/acl:1.0.9.x-devSpatie\Permission\PermissionServiceProvider::class,
Modules\Acl\Providers\AclServiceProvider::class,composer dump-autoloadphp artisan vendor:publishSpatie Permission publish must be before ACL publish
Choose --provider="Spatie\Permission\PermissionServiceProvider"
Then you need to publish acl-config tag
This will create configuration file to this config/acl.php path. You can modify some configuration here. If you don't want to change anything you can skip this tag publishing step.
Choose --provider="Modules\Acl\Providers\AclServiceProvider"
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
'api.json' => \Modules\Acl\Http\Middleware\JsonMiddleware::class,
'verify.token' => \Modules\Acl\Http\Middleware\TokenValidationMiddleware::class,$this->call(AclDatabaseSeeder::class);create_user_profile_table.php this is our default profile table. You are free to delete this if profile already exists
use Spatie\Permission\Traits\HasRoles;
use Modules\Acl\Traits\SoftDeletes;use HasRoles, SoftDeletes;Add deleted_by in your User Models $fillable array AND email_verified_at in your $hidden array. Then add this in your User Model
protected static function boot()
{
parent::boot();
static::restoring(function ($model) {
$model->deleted_by = null;
});
}php artisan migrate:fresh --seedphp artisan migrate
php artisan db:seed --class=AclDatabaseSeederIf using Docker on MAC OS, need to use '${VITE_PORT:-5173}:${VITE_PORT:-5173}' Port number can be changed. Example:
app:
build:
args:
user: www
uid: 1000
context: ./
dockerfile: Dockerfile
image: laravel-image
container_name: laravel-app
ports:
- '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
restart: unless-stopped
working_dir: /var/www/
depends_on:
- mysqlcomposer require laravel/socialite'google' => [
'client_id' => env('GOOGLE_CLIENT_ID'),
'client_secret' => env('GOOGLE_CLIENT_SECRET'),
'domains' => env('GOOGLE_EMAIL_DOMAIN', 'yourdomain.edu'),
'redirect' => env('APP_URL').'/login/google/callback'
],- Md. Tanjil Hasan