I am working on search. I am facing issue with the query. when ever i search super. It gives me super admin user also but i am using ->whereRelation(‘role’,’name’, ‘teacher’) Answer that because if any orWhere come with true, the record will be fetched, you should group your orWhere in one statment:
Tag: laravel-relations
How to find data based on Many To Many relationship in Laravel 5.8
I have a Many To Many relationship between User Model & Wallet Model: Wallet.php: And User.php: And I have these three tables related to Wallets: Table wallets: Table user_wallet: And table user_wallet_transactions: Now I need to show wallets of a single user. So at the users.index Blade, I added this: And send the user data to Controller like this: But
How to get all the people in table 1 without getting the people who have me as parent_id in table 2?
I’m writing this post because I have a problem with my relationships on Laravel. Here is the structure I currently have: 1st table: – id – name – … 2nd table : – parent_id – child_id knowing that …