laravel-auditing
laravel-auditing copied to clipboard
Way to use the package without the use of Auth?
| Q | A |
|---|---|
| Bug? | no |
| New Feature? | yes |
| Framework | Laravel |
| Framework version | 9.0.2 |
| Package version | 13.0.3 |
| PHP version | 8.0.8 |
Actual Behaviour
I do not use Auth for users in my service. I see that the implementation of the UserResolver is this:
Is there any way to do something like:
$morphPrefix . '_id' => $user ? $user->id : null,
$morphPrefix . '_type' => $user ? $user->type: null,
instead of
$morphPrefix . '_id' => $user ? $user->getAuthIdentifier() : null,
$morphPrefix . '_type' => $user ? $user->getMorphClass() : null,
Expected Behaviour
Because I just want to use the model that I return in my resolver:
<?php
namespace App\Resolvers;
use Illuminate\Support\Facades\Request;
use App\DataServiceModels\User;
class UserResolver implements \OwenIt\Auditing\Contracts\UserResolver
{
/**
* {@inheritdoc}
*/
public static function resolve()
{
$current_user = User::where(['user_id' => Request::get('user_id'), 'type' => Request::get('user_type')])->get();
$current_user = count($current_user) > 0 ? $current_user[0] : null;
return $current_user;
}
}
Possible Solutions
Make that part configurable? Or is there any way that I can achieve what I am looking for?
Thanks!
You can change everything on config, just read documentation
I have read the documentation multiple times before opening this issue :) I was not able to find, or at least understand what I can use to achieve this... Could you please at least show me which part of the documentation might help me with this?
Did you try adding getAuthIdentifier() on user model
public function getAuthIdentifier(){
return $this->id;
}
Closed due to inactivity