Invite.php 661 B

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