PHP code example of grazulex / laravel-multipersona
1. Go to this page and download the library: Download grazulex/laravel-multipersona 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/ */
grazulex / laravel-multipersona example snippets
// Get current active persona
$currentPersona = persona();
// List all user personas
$userPersonas = auth()->user()->personas;
// Create a new persona
$persona = auth()->user()->createPersona([
'name' => 'Company Admin',
'context' => [
'role' => 'admin',
'company_id' => 123,
'permissions' => ['read', 'write', 'delete']
]
]);
// Switch to persona
auth()->user()->switchToPersona($persona);