Invite.php 617 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Http\Models;
  3. use Auth;
  4. use Eloquent;
  5. use Illuminate\Database\Eloquent\Model;
  6. use Illuminate\Database\Eloquent\SoftDeletes;
  7. /**
  8. * 邀请码
  9. * Class Invite
  10. *
  11. * @package App\Http\Models
  12. * @mixin Eloquent
  13. */
  14. class Invite extends Model
  15. {
  16. use SoftDeletes;
  17. protected $table = 'invite';
  18. protected $primaryKey = 'id';
  19. protected $dates = ['deleted_at'];
  20. function scopeUid($query)
  21. {
  22. return $query->where('uid', Auth::user()->id);
  23. }
  24. function generator()
  25. {
  26. return $this->hasOne(User::class, 'id', 'uid');
  27. }
  28. function user()
  29. {
  30. return $this->hasOne(User::class, 'id', 'fuid');
  31. }
  32. }