123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <?php
- namespace App\Http\Models;
- use Auth;
- use Eloquent;
- use Illuminate\Database\Eloquent\Builder;
- use Illuminate\Database\Eloquent\Collection;
- use Illuminate\Foundation\Auth\User as Authenticatable;
- use Illuminate\Notifications\DatabaseNotification;
- use Illuminate\Notifications\DatabaseNotificationCollection;
- use Illuminate\Notifications\Notifiable;
- use Illuminate\Support\Carbon;
- class User extends Authenticatable
- {
- use Notifiable;
- protected $table = 'user';
- protected $primaryKey = 'id';
- function scopeUid($query)
- {
- return $query->whereId(Auth::user()->id);
- }
- function levelList()
- {
- return $this->hasOne(Level::class, 'level', 'level');
- }
- function payment()
- {
- return $this->hasMany(Payment::class, 'user_id', 'id');
- }
- function label()
- {
- return $this->hasMany(UserLabel::class, 'user_id', 'id');
- }
- function subscribe()
- {
- return $this->hasOne(UserSubscribe::class, 'user_id', 'id');
- }
- function referral()
- {
- return $this->hasOne(User::class, 'id', 'referral_uid');
- }
- function getBalanceAttribute($value)
- {
- return $value/100;
- }
- function setBalanceAttribute($value)
- {
- return $this->attributes['balance'] = $value*100;
- }
- }
|