<?php

namespace App\Models;

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

class ShopOrderShare extends BaseModel
{
    use HasFactory;

    public $fillable = ['user_id', 'order_id', 'trade_no', 'amount','status', 'reason'];

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }

    public function scopeStatus($query)
    {
        $status = request()->status;
        if ($status) return $query->where("status", $status);
        return $query;
    }
}
