Laravel 4: left join with where claus not showing none linked rows -


I am trying to create an artisan cron job in Laravel 4 which is available to all the subscribers, who are known for the well-known ORM Should use. I am trying to accomplish that at least one month ago I subscribe to all the consumers who have paid the last time or new subscriptions that were never paid. Even though I only get information from the user table (user 1 and 3), the value of the pay table is 'null', that means that they are not with the limit, although I only want to say 'null' if they have a table There is no value in the payments.

My code:

  $ ('Payments.user_id', '=', 'user.id') - & gt; ('Payments.paid_on') (payment 'payday_on'), date ("D"), date ("Y"), '& lt; = ', Date (' YMD HH: I: S ', MKTEM (0, 0, 0, Date ("M")) - & gt; Where ('payments.paid_on', '& gt; =', Date ('YMD H: I: S', Mktm (0, 0, 0, Date ("M") -1, Date ("D") - 10, Date ("Y"))));}) - & gt; Where ('user.start', '& lt;', Date ('YMD H: I: S', Time ()) - & Gt; Where ('user.end', '& gt;', Date ('YMD H: I: S', Time ())) - & gt; (Get 'user. *', 'Payments.paid_on']);   

An example of this data is:

  (user) ID End start | 1 | 2014-02-24 00:00:00 | 2015-02-24 00:00:00 | 2 | 2012-03-24 00:00:00 | 2013-01-24 00:00 : 00 | | 3 | 2014-03-24 00:00:00 | 2015-03-24 00:00:00 | (payment) user_id Paid_on | 1 | 2014-02-24 00:00:00 | 1 | 2014-03-24 00:00:00 | 2 | 2013-01-24 00:00:00 |   

I hope that something like this will be done: < Pre> | 1 | 2014-02-24 00:00:00 | 2015-02-24 00:00:00 | 1 | 2014-03-24 00:00:00 | 3 | 2014-03- 24 00:00:00 | 2015-03-24 00:00:00 |

Do not know that I have come to the right conclusion But this is what I have ended, check above whether the value exists in the right table where the block and if I did not check whether there is one for zero, the code is here:

  $ payments = user: left zones ('payment', 'user.id', '=', 'payments.user_id') - & gt; Where ('User (' UMD HK: I: S ', Time ()) - & gt; Where ('user.and', '& gt;', date ('YMD HK: I: S', time ()) -> where (function ($ query) {$ query- & gt; where (' Payments.paid_on ',' & lt; = ', Date (' Ymd H: i: s', mktime (0, 0, 0, Date ("m") - 1, Date ("D"), Date (" Y ')))) - where (' payments.paid_on ',' & gt; = ', date (' YMD H: I: S ', mktm (0, 0, 0, date ("m") - 1, date ("D") - 5, date ("Y"))) -> ($ OrQuery) {$ orQuery-> where tap ('payments.paid');}); } - & gt; Receive (['Users. *', 'Payments.paid_on']);    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -