1. Go to this page and download the library: Download agednerd/laravel-masquerade 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/ */
agednerd / laravel-masquerade example snippets
use AgedNerd\Masquerade\Concerns\Masqueradable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Masqueradable;
public function canMasquerade(?AuthenticatableContract $subject = null): bool
{
return $this->is_admin && ! $subject?->is_admin;
}
public function canBeMasqueraded(?AuthenticatableContract $masquerader = null): bool
{
return ! $this->is_admin;
}
}
use Illuminate\Support\Facades\Route;
Route::middleware('web')->group(function (): void {
Route::masquerade();
});