User.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. class User extends Authenticatable
  7. {
  8. use Notifiable;
  9. /**
  10. * The attributes that are mass assignable.
  11. *
  12. * @var array
  13. */
  14. protected $fillable = [
  15. 'name', 'email', 'password', 'surname', 'username', 'day', 'month',
  16. 'year', 'skill', 'about', 'balance', 'country_id', 'city_id',
  17. 'group', 'ban_info', 'avatar_url', 'status_text', 'dob', 'verify'
  18. ];
  19. /**
  20. * The attributes that should be hidden for arrays.
  21. *
  22. * @var array
  23. */
  24. protected $hidden = [
  25. 'password', 'remember_token',
  26. ];
  27. /**
  28. * The attributes that should be cast to native types.
  29. *
  30. * @var array
  31. */
  32. protected $casts = [
  33. 'email_verified_at' => 'datetime',
  34. ];
  35. private $online_minutes = 15;
  36. public function city()
  37. {
  38. return $this->hasOne('App\City', 'id', 'city_id');
  39. }
  40. public function country()
  41. {
  42. return $this->hasOne('App\Country', 'id', 'country_id');
  43. }
  44. public function articles()
  45. {
  46. return $this->hasMany('App\Article', 'user_id', 'id')->latest();
  47. }
  48. public function online()
  49. {
  50. $control_time = $this->online_minutes * 60;
  51. return ((time() - $this->online) > $control_time) ? false : true;
  52. }
  53. }