Please post your "Transporter Model" so we can see your relation functions - I think that would help.
Jan 19, 2018
4
Level 1
How to get all data in table A where not has a foreign key in it's child table B and unlike same relation
i have 3 tables tbl_Transporters , tbl_Transactions and tbl_TransactionStatus where table tbl_transporter has (hasMany) relationship with tbl_transaction and tbl_Transaction has (belongsTo) also tbl_Transporter has (hasOne) relations with tbl_Transaction and tbl_Transaction (belongsTo).
what i want is:
with ID of tbl_Transporters which i have , how can i get all those Transactions from tbl_Transactions where it not exist in tbl_TransactionStatus. and in second query all those transactions from tbl_Transactions where it exist in tbl_TransactionStatus .
please thank you.
Level 40
Here's my guess:
$xport = Transport::find($transporter_id);
$with_status = $xport->transactions()->has('transactionstatus')->get();
$no_status = xport->transactions()->doesntHave('transactionstatus')->get();
1 like
Please or to participate in this conversation.