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