Issue
I want to select only the products that have a record in the relational table in the selectbox.
For example I just want to get product name which is product_id
in the monthly_records
table
Tables;
Products(ID, product_name)
Suppliers(ID, supplier_name)
monthly_records(ID,pruduct_id,supplier_id,date)
Solution
Eloquent has() method is what you are looking for. With that you can do something like:
Product::has('monthlyRecords')->pluck('name');
Answered By - P. K. Tharindu
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.