-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ErrorException Undefined index: user #282
Comments
Show me the |
audit.php <?php
return [
/*
|--------------------------------------------------------------------------
| Audit implementation
|--------------------------------------------------------------------------
|
| Define which Audit model implementation should be used.
|
*/
'implementation' => OwenIt\Auditing\Models\Audit::class,
/*
|--------------------------------------------------------------------------
| User Keys, Model & Resolver
|--------------------------------------------------------------------------
|
| Define the User primary and foreign keys, Eloquent model and ID resolver
| class.
|
*/
'user' => [
'primary_key' => 'id',
'foreign_key' => 'user_id',
'model' => \App\Models\Database\User::class,
'resolver' => function()
{
return Auth::check() ? Auth::user()->getAuthIdentifier() : null;
},
],
/*
|--------------------------------------------------------------------------
| Default Driver
|--------------------------------------------------------------------------
|
| The default audit driver used to keep track of changes.
|
*/
'default' => 'database',
/*
|--------------------------------------------------------------------------
| Audit Drivers
|--------------------------------------------------------------------------
|
| Available audit drivers and respective configurations.
|
*/
'drivers' => [
'database' => [
'table' => 'audits',
'connection' => env('DB_CONNECTION', 'mysql'),
],
],
/*
|--------------------------------------------------------------------------
| Audit Console?
|--------------------------------------------------------------------------
|
| Whether we should audit console events (eg. php artisan db:seed).
|
*/
'console' => false,
]; MyModel is just one model around several others, it's similar to this one <?php
namespace App\Models\Database;
use App\Models\Model as Eloquent;
use OwenIt\Auditing\Auditable;
use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
class MyModel extends Eloquent implements AuditableContract
{
use Auditable;
} User <?php
namespace App\Models\Database;
use App\Models\Model as Eloquent;
use OwenIt\Auditing\Auditable;
use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
class User extends Eloquent implements AuditableContract
{
use Auditable;
} I try to use model as basic as possible and I got the same behaviour. Note : all my dev are made with error_reporting = E_ALL |
Sorry, I can't reproduce the issue. You say that if you replace if ($user = $this->getRelation('user')) { with if ($user = $this->user) { it works? If you |
I got a user or null following if there is a connected user. |
Can you rephrase that?
If you have |
I try to reproduce the case with a clean fresh laravel installation with just this package (so with the default user model). Foo.php <?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use OwenIt\Auditing\Auditable;
use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
class Foo extends Model implements AuditableContract
{
use Auditable;
//
public $timestamps = false;
protected $fillable = [
'name',
];
} Simple table, with a simple attribute \App\Foo::create(['name' => 'abc-' . uniqid()]); foreach(\App\Foo::all() as $foo)
{
dump($foo->audits()->first()->getMetadata());
} exactly the same error. edit: But in my project example, in the case where ->user is not null I still have the same error. |
Try: |
With |
Yeah, I'll have to change that again. We shouldn't be forced to pass |
Fixed in the latest version. |
Thanks. That was fast
Le 3 août 2017 17:36, "Quetzy Garcia" <[email protected]> a écrit :
… Fixed in the latest version.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#282 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAo0hBifa1xJtoZ0rj94krKPzvsYwVvgks5sUekFgaJpZM4OsQmn>
.
|
Actual Behaviour
An error of undefined index appears
Expected Behaviour
No error ;)
Steps to Reproduce
ErrorException Undefined index: user
no error with:
Possible Solutions
inside \OwenIt\Auditing\Audit::resolveData
replace
by
The text was updated successfully, but these errors were encountered: