User.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Auth\Authenticatable;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Auth\Passwords\CanResetPassword;
  6. use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
  7. use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
  8. class User extends Model implements AuthenticatableContract, CanResetPasswordContract
  9. {
  10. use Authenticatable, CanResetPassword;
  11. /**
  12. * The attributes that are mass assignable.
  13. *
  14. * @var array
  15. */
  16. protected $fillable = [
  17. 'name', 'email', 'password', 'is_admin', 'level', 'score'
  18. ];
  19. /**
  20. * The attributes excluded from the model's JSON form.
  21. *
  22. * @var array
  23. */
  24. protected $hidden = [
  25. 'password', 'remember_token',
  26. ];
  27. public function posts()
  28. {
  29. return $this->hasMany('App\Models\Post');
  30. }
  31. public static $rules = array(
  32. 'name' => 'required',
  33. 'email' => 'unique:users',
  34. 'password' => 'required'
  35. );
  36. }