123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace App\Http\Models;
- use Auth;
- use Eloquent;
- use Illuminate\Database\Eloquent\Builder;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Support\Carbon;
- class ReferralLog extends Model
- {
- protected $table = 'referral_log';
- protected $primaryKey = 'id';
- function scopeUid($query)
- {
- return $query->whereRefUserId(Auth::user()->id);
- }
- function user()
- {
- return $this->hasOne(User::class, 'id', 'user_id');
- }
- function ref_user()
- {
- return $this->hasOne(User::class, 'id', 'ref_user_id');
- }
- function order()
- {
- return $this->hasOne(Order::class, 'oid', 'order_id');
- }
- function getAmountAttribute($value)
- {
- return $value/100;
- }
- function setAmountAttribute($value)
- {
- $this->attributes['amount'] = $value*100;
- }
- function getRefAmountAttribute($value)
- {
- return $value/100;
- }
- function setRefAmountAttribute($value)
- {
- $this->attributes['ref_amount'] = $value*100;
- }
- }
|