2 years ago

Converting join sql statement to eloquent.

Posted 2 years ago by bobmyles

I have three models.

  1. ScheduledMessage points to table scheduled_messages.
  2. SubscribedService points to table subscribed_services.
  3. SubscriptionServicesMsisdn points to table subscription_services_msisdn.

I have raw sql query that I would want to convert into eloquent but can not think of a way.

SQL Query:

  b.message, c. phone_number, a.username, a.password from subscribed_services a 
inner join 
  subscription_services_msisdn c on = c.subscribed_services_id 
inner join 
 scheduled_messages b on = b.subscribed_services_id where DATE(b.scheduled_at) = CURDATE()

Would someone please help convert to eloquent. Thank you.

Please sign in or create an account to participate in this conversation.