UserLabel.php 1012 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Http\Models;
  3. use Auth;
  4. use Eloquent;
  5. use Illuminate\Database\Eloquent\Builder;
  6. use Illuminate\Database\Eloquent\Model;
  7. /**
  8. * 用户标签
  9. * Class UserLabel
  10. *
  11. * @package App\Http\Models
  12. * @mixin Eloquent
  13. * @property int $id
  14. * @property int $user_id 用户ID
  15. * @property int $label_id 标签ID
  16. * @property-read User $user
  17. * @method static Builder|UserLabel newModelQuery()
  18. * @method static Builder|UserLabel newQuery()
  19. * @method static Builder|UserLabel query()
  20. * @method static Builder|UserLabel uid()
  21. * @method static Builder|UserLabel whereId($value)
  22. * @method static Builder|UserLabel whereLabelId($value)
  23. * @method static Builder|UserLabel whereUserId($value)
  24. */
  25. class UserLabel extends Model
  26. {
  27. public $timestamps = FALSE;
  28. protected $table = 'user_label';
  29. protected $primaryKey = 'id';
  30. function scopeUid($query)
  31. {
  32. return $query->whereUserId(Auth::user()->id);
  33. }
  34. function user()
  35. {
  36. return $this->hasOne(User::class, 'id', 'user_id');
  37. }
  38. }