You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Blamable.php 472B

12345678910111213141516171819202122
  1. <?php
  2. namespace App\Traits;
  3. use Illuminate\Support\Facades\Auth;
  4. trait Blamable
  5. {
  6. public static function bootBlamable(): void
  7. {
  8. $auth = Auth::check() ? Auth::id() : null;
  9. static::creating(static function ($model) use ($auth) {
  10. $model->created_by = $auth;
  11. $model->updated_by = $auth;
  12. });
  13. static::updating(static function ($model) use ($auth) {
  14. $model->updated_by = $auth;
  15. });
  16. }
  17. }