PHP code example of lechuganegra / accessmanager

1. Go to this page and download the library: Download lechuganegra/accessmanager 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/ */

    

lechuganegra / accessmanager example snippets


    'user_entity' => [
        'model' => App\Models\User::class, // Reemplaza con tu modelo
        'table' => 'users' // Reemplaza con el nombre de tu tabla
    ],
    

Route::middleware(['capability.access'])->group(function () {
    // Rutas protegidas
});

use Lechuganegra\AccessManager\Models\RelationEntityRole;

public function roles()
{
    return $this->morphMany(RelationEntityRole::class, 'entity', 'entity_type', 'entity_id');
}

use Illuminate\Database\Eloquent\Relations\Relation;

Relation::morphMap([
    'user' => \App\Models\User::class,
]);
bash
    php artisan vendor:publish --tag=accessmanager-config

    
bash
    php artisan migrate --path=packages/lechuganegra/accessmanager/src/Database/Migrations
    
bash
    php artisan db:seed --class="LechugaNegra\\AccessManager\\Database\\Seeders\\DatabaseSeeder"
    
bash
    php artisan config:clear
    php artisan config:cache
    php artisan route:clear
    php artisan route:cache
    
bash
    composer dump-autoload
    
bash
php artisan accessmanager:check
bash
php artisan migrate --path=packages/lechuganegra/accessmanager/src/Database/Migrations