PHP code example of ingenius / auth

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

    

ingenius / auth example snippets


use Ingenius\Auth\Helpers\AuthHelper;

// Get authenticated user from any guard
$user = AuthHelper::getUser();

// Check if user is authenticated in any guard
if (AuthHelper::check()) {
   // User is authenticated
}

// Get user from a specific guard
$tenantUser = AuthHelper::getUserFromGuard('tenant');
$sanctumUser = AuthHelper::getUserFromGuard('sanctum');

// In your routes file
Route::middleware(['tenant.user'])->group(function () {
    Route::get('/dashboard', 'DashboardController@index');
});

Route::middleware(['tenant.user', 'tenant.permission:auth.users.view'])->group(function () {
    Route::get('/users', 'UserController@index');
});
bash
php artisan vendor:publish --tag=ingenius-auth-config
bash
php artisan vendor:publish --tag=ingenius-auth-migrations
bash
php artisan migrate