'در انتظار واریز', 2 => 'واریز شد', 4 => 'واریز توسط ادمین', 5 => 'پاداش معرفی', 9 => 'سود زیر مجموعه', 3 => 'واریز ناموفق', 50 => 'در انتظار ارسال', 51 => 'ارسال شده', 52 => 'لغو شده', ]; public function customer() { return $this->belongsTo('App\Models\Customer')->select(['id', 'name', 'mobile']); } public function Address() { return $this->belongsTo('App\Models\Address'); } public function Transaction() { return $this->hasMany(Transaction::class, 'withdraw_id', 'id'); } public function bank_account() { return $this->hasOne('App\Models\BankAccount', 'id', 'bank_account_id'); } public static function applyFlowFilter($query, ?string $flowType = 'all') { if (!$flowType || $flowType === 'all') { return $query; } if ($flowType === 'withdraw') { return $query->where(function ($q) { $q->where('note', 'like', '%برداشت%') ->orWhere('type', 2) ->orWhereBetween('sts', [50, 52]); }); } if ($flowType === 'deposit') { return $query->where(function ($q) { $q->where('note', 'like', '%واریز%') ->orWhere('type', 1) ->orWhere(function ($admin) { $admin->where('sts', 4) ->where(function ($note) { $note->whereNull('note') ->orWhere('note', 'not like', '%برداشت%'); }); }); }); } return $query; } }