WildsideUK / Laravel-Userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `created_by` and `updated_by` columns on your model, populated by the currently authenticated user in your application.
https://wildside.uk
MIT License
570 stars 64 forks source link

Update doesn't work #10

Closed tanhs closed 7 years ago

tanhs commented 7 years ago

I tried the following it doesn't work

  1. create new - it updates all including the updated_by & created_by
  2. I tried to update the record, i use "save()" or "update()" both no effect. Do you have any clue?

User.php use Laratrust\Traits\LaratrustUserTrait; use Wildside\Userstamps\Userstamps;

class User extends Authenticatable { use Notifiable; use LaratrustUserTrait; use Userstamps;

protected $fillable = [
    'name', 'email', 'password', 'created_at', 'updated_at', 'created_by', 'updated_by'
];

...

mattmcdonald-uk commented 7 years ago

Did you have an active user when you tested saving and updating a model? If there's no user to be found the created_by and updated_by fields will remain null.

Other than that, difficult to assist here without a specific bug.

lucianobosco commented 5 years ago

Same issue here. updated_by column is not set when using update() method

$updated_customer['name'] = 'John Doe';
$customer = Customer::findOrFail($request->id);
$customer->update($updated_customer);