php - Laravel Get all realated models with scope -
I've been stuck for some days trying to get something I think should really be simple, but I I am not able to find the right solution,
I have the following models (just printing important methods)
order
id
Created_at
Communications
ID
order_id
I have an opportunity in order
scopeByRange ( $ Query, $ d1, $ D2) {return $ query- & gt; Where between ('created', [$ d1, $ d2])} which works perfectly, what do I have to achieve
$ OrderContents = order :: byRange ($ d1, $ d2) - & gt; AllOrderContents;
So I do not have to make an attempt to merge and merge the collections
Is there any way?
Thanks to @Jarek Tuckzezky for pointing me in the right direction, my last job is the following, Just do something extra calculation for the report
Public stable work by datrerence ($ d1, $ d2) {$ orderContents = null; Order :: By Date Rate ($ d1, $ d2) - & gt; (Use the ['contents' = & gt; function ($ q) (& amp; $ order content) {$ orderContents = $ q- & gt; select ('*' db :: raw ('amount' quantity ('Total_sum', 'dexc') - (in the form of total sum) '-' ('total_sum') - & gt; groupB ('item_id') - & gt; & Gt; Received () - & gt; Unique ();}, 'contents.item']) - & gt; get (); Return $ order; }
Comments
Post a Comment