Do you already have Payment Model and Ticket Model?
Nov 15, 2017
7
Level 1
Convert mysql query to laravel ORM query
I want convert mysql query to laravel ORM query, anyone can help...
Here the Sql Query...
query('SELECT PAYMENT, TOTAL, TRANSID FROM PAYMENTS WHERE RECEIPT = (select ID from tickets WHERE TICKETID = ?)'
Level 41
Try something along those lines
$receipt = Ticket::where('ticketid', 'Your ticket ID')->first();
$payment = Payment::where('receipt', $receipt->id)->get();
But do have a look at eloquent relations: https://laravel.com/docs/5.5/eloquent-relationships#one-to-one
It would make your life easier
1 like
Please or to participate in this conversation.