Level 70
What if you try this-
return $this->deposits->where('txid', '!=', NULL)->sum('amount');
9 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Since collections don't support "whereNotNull()", what's the best way to do something like:
public function getTotalInvestedAmountAttribute()
{
return $this->deposits->whereNotNull('txid')->sum('amount');
}
The whereNotNull() statement cannot be used, because it's a collection.
What if you try this-
return $this->deposits->where('txid', '!=', NULL)->sum('amount');
Please or to participate in this conversation.