<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class AgentEarning extends BaseModel
{
    use HasFactory;

    public $fillable = ['user_id', 'order_id', 'total', 'amount', 'ufutx_amount', 'wechat_fee', 'ufutx_fee', 'shop_id'];

    public function scopeUser($query, $user_id=null)
    {
        if ($user_id) {
            return $query->where('user_id', $user_id);
        }
        return $query;
    }

//    public function order()
//    {
//        return $this->hasOne(TouristOrder::class, 'id', 'order_id');
//    }
    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }
    public function shop()
    {
        return $this->belongsTo(Shop::class, 'shop_id', 'id');
    }
}
