選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Blamable.php 460B

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. static::creating(static function ($model) {
  9. $auth = Auth::id();
  10. $model->created_by = $auth;
  11. $model->updated_by = $auth;
  12. });
  13. static::updating(static function ($model) {
  14. $auth = Auth::id();
  15. $model->updated_by = $auth;
  16. });
  17. }
  18. }