PHP code example of mevisoft / auth-accounts-luisml
1. Go to this page and download the library: Download mevisoft/auth-accounts-luisml 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/ */
use LuisML\AccountsClient\Concerns\HasAccountsRoles;
use LuisML\AccountsClient\Roles;
class User extends Authenticatable
{
use HasAccountsRoles; // columna accounts_roles (la añade la migración del paquete)
}
$user->hasAccountsRole(Roles::ADMIN);
public function __invoke(Identity $identity): ?Authenticatable
{
$user = ($this->resolveModelUser)($identity); // LuisML\AccountsClient\Actions\ResolveModelUser
if ($user?->wasRecentlyCreated) {
// crear equipo personal, asignar rol por defecto, etc.
}
return $user;
}