User.php 902 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App;
  3. use Illuminate\Contracts\Auth\MustVerifyEmail;
  4. use Illuminate\Foundation\Auth\User as Authenticatable;
  5. use Illuminate\Notifications\Notifiable;
  6. use Illuminate\Support\Str;
  7. class User extends Authenticatable
  8. {
  9. use Notifiable;
  10. /**
  11. * The attributes that are mass assignable.
  12. *
  13. * @var array
  14. */
  15. protected $fillable = [
  16. 'name', 'login', 'password', 'avatar'
  17. ];
  18. /**
  19. * The attributes that should be hidden for arrays.
  20. *
  21. * @var array
  22. */
  23. protected $hidden = [
  24. 'password',
  25. ];
  26. /**
  27. * The attributes that should be cast to native types.
  28. *
  29. * @var array
  30. */
  31. protected $casts = [
  32. 'email_verified_at' => 'datetime',
  33. ];
  34. public $timestamps = false;
  35. public function generateToken()
  36. {
  37. $this->api_token = Str::random(32);
  38. $this->save();
  39. }
  40. }