<?php

namespace App\Models;

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

class AgentWithdraw extends BaseModel
{
    use HasFactory;
    public $fillable = ['user_id', 'amount', 'status', 'comment'];

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

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

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