Closed adriandmitroca closed 4 years ago
nova.guard
is null by default, I might need to think of another solution here.
You could overwrite the Notes model and the createdBy() method, that'll work.
Hmm yeah that's option, but imho this should still respect Nova's guard. Perhaps with extra condition to check if guard is set instead of forcing it always?
$novaGuard = config('nova.guard');
$userClass = !empty($novaGuard)
? config('auth.providers.' . config('auth.guards.' . $novaGuard . '.provider') . '.model')
: config('auth.providers.users.model');
Does this seem to suffice?
Exactly what I had in mind. I have just updated my PR :)
Cheers! Released in version 1.5.3.
I see that you have simplified code (https://github.com/optimistdigital/nova-notes-field/commit/2fcf0b8613d37d0b4269bd7bc7b864793f4d3b48) however this led to new bug.
Nova Guard isn't equal to auth provider, but auth guard instead. Based on that guard, you should search for relevant provider.
This was done here: https://github.com/optimistdigital/nova-notes-field/pull/17/files#diff-7a1e55e3c25f0de16f8bbfcea9501658R32
Currently, when nova.guard is set, you always get a null :(
Ah crap! That's pretty dumb, sorry about that! Released a fix in version 1.5.4. Thanks!
Thanks dude! It's great to be able to remove custom fork from composer.json 🤗
Thanks to this change current User model is not hardcoded, also it inherits guard from Nova config which is used for entire authentication.
Use case: Admin as a separated model.