'در انتظار تایید', // 2=>'تایید شده', // 3=>'رد شده', // ]; public function getNoteAttribute($value): ?string { $order = null; if ($this->relationLoaded('order')) { $order = $this->order; } elseif ($this->order_id) { $order = $this->order()->with('product')->first(); } if ($order) { $productTitle = null; if ($order->relationLoaded('product') && $order->product) { $productTitle = $order->product->title; } elseif ($order->product_id) { $productTitle = Product::query()->whereKey($order->product_id)->value('title'); } $productTitle = trim((string) $productTitle); if ($productTitle === '') { $productTitle = Controller::mainWalletProductLabel() ?: 'مس'; } $direction = (int) ($order->direction ?? 0); if ($direction === 1) { return 'خرید ' . $productTitle; } elseif ($direction === 2) { return 'فروش ' . $productTitle; } } if (is_string($value)) { if (str_contains($value, 'آبشده') || str_contains($value, 'طلای آبشده')) { $defaultTitle = Controller::mainWalletProductLabel() ?: 'مس'; return str_replace(['طلای آبشده', 'آبشده'], $defaultTitle, $value); } } return $value; } public function customer() { return $this->belongsTo(Customer::class); } public function customerTo() { return $this->belongsTo(Customer::class, 'customer_to_id'); } public function user() { return $this->belongsTo(User::class); } public function order() { return $this->belongsTo(Order::class); } // public function transaction() // { // return $this->belongsTo(\Rooyesh\Wallet\Models\Transaction::class, 'transaction_id'); // } public function withdraw() { return $this->belongsTo(Withdraw::class); } }