/nova-impersonate

A Laravel Nova field allows you to authenticate as your users.

Primary LanguagePHPMIT LicenseMIT

Nova Impersonate Field

Latest Version on Packagist Total Downloads

This field allows you to authenticate as your users.

screenshot1 screenshot2 screenshot3

Behind the scenes 404labfr/laravel-impersonate is used.

Installation

You can install the package in to a Laravel app that uses Nova via composer:

composer require kabbouchi/nova-impersonate
php artisan vendor:publish --tag=nova-impersonate-views

Usage

Add Impersonate::make($this->id) field in App\Nova\User.php

<?php

namespace App\Nova;

use KABBOUCHI\NovaImpersonate\Impersonate;

...

class User extends Resource
{
	...
	
	public function fields(Request $request)
	{
		return [
			ID::make()->sortable(),

			Gravatar::make(),

			Text::make('Name')
				->sortable()
				->rules('required', 'max:255'),

			Text::make('Email')
				->sortable()
				->rules('required', 'email', 'max:255')
				->creationRules('unique:users,email')
				->updateRules('unique:users,email,{{resourceId}}'),

			Password::make('Password')
				->onlyOnForms()
				->creationRules('required', 'string', 'min:6')
				->updateRules('nullable', 'string', 'min:6'),


			Impersonate::make($this->id),  // <---
			
			// or
			Impersonate::make()->withMeta([ 'id' => $this->id  ]),
			
			// or
			Impersonate::make()->withMeta([
			    'id' => $this->id,
			    'hideText' => false,
			]),

		];
	}

    ...
}

Credits

The MIT License (MIT). Please see License File for more information.