Closed z4yed closed 3 months ago
If you look at the table action...
https://github.com/stechstudio/filament-impersonate/blob/master/src/Tables/Actions/Impersonate.php#L20C13-L20C66
... you can see how the current $record
is being passed to the impersonate method. In theory, if the current $record
is an instructor, you could probably do this:
Impersonate::make()
->redirectTo('/instructor')
->action(fn ($record) => $this->impersonate($record->user))
This is untested, but it seems like this sort of approach should work. I think you just need to manually handle the action, and tell the impersonate method where the actual user model is.
->actions([
Impersonate::make()
->redirectTo('/instructor')
->action(fn($record) => $this->impersonate($record->user)),
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
I am having the same issue. Tried to override the record method but did not work as well
@z4yed This should work:
->actions([
Impersonate::make()
->action(fn(Interpreter $record, Impersonate $action) => $action->impersonate($record->user)),
Tables\Actions\EditAction::make(),
])
@AurelDemiri awesome! Thanks.
I have a resource named
InstructorResource
. TheInstructor
model has a relationaluser
method which belongs toUser
model.I am trying to impersonate from InstructorResource by:
From the
UserResource
class, it is working perfectly though. Is it possible to impersonate fromInstructResource
?