Hi,
I have a scenario that I don't want to query the database 4 times so my first line of code is:
$proposals = ProposalModel::get();
Now I want to fetch all pending proposals, (that is working)
$pending = $proposals->where('status', 'pending');
But, for the approved, submitted and declined proposals, I want to fetch the records according to dates. For example, get records of approved proposal of last 30 days
$approved = $proposals->where('status', 'approved')->where('created_at', '>=', \Carbon\Carbon::now()->subMonth());
created_at is datetime field in database.
Is it possible, not permitted, or else? Please let me know how can I do that. Again, I don't want to query database again and again for all 4 different statuses of my proposal.
Thanks and Regards,