Skip to content
Advertisement

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:

JavaScript

And User.php:

JavaScript

And I have these three tables related to Wallets:

Table wallets:

JavaScript

Table user_wallet:

JavaScript

And table user_wallet_transactions:

JavaScript

Now I need to show wallets of a single user. So at the users.index Blade, I added this:

JavaScript

And send the user data to Controller like this:

JavaScript

But I don’t know how to retrieve user_wallet information at this Method.

So how to get data from user_wallet in this situation.

I would really appreciate any idea or suggestion from you guys about this…

Thanks in advance.

Advertisement

Answer

One way is accept param as $id

JavaScript

then

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement