hipsterjazzbo / Landlord

A simple, single database multi-tenancy solution for Laravel 5.2+
MIT License
615 stars 138 forks source link

Landlord does not work in Laravel 5.6 #98

Open jackrsantana opened 6 years ago

jackrsantana commented 6 years ago

Hello

I'm trying to use LandLord in a Laravel 5.6 project but it refuses to work.

Follow the steps I've taken.

1-I changed the composer.json file as indicated in issue #93: https://i.imgur.com/UXgnqdG.png

2-I added the entries in the file config / app.php https://i.imgur.com/TN3ZbL1.png https://i.imgur.com/IEADLG5.png

3-I ran the composer update command followed by the php artisan vendor command: publish --provider = "HipsterJazzbo\Landlord\LandlordServiceProvider"

4-I created a Middleware to add the necessary tenants: https://i.imgur.com/9NiwEJC.png

5-Add it to Kernel.php: https://i.imgur.com/4Hotu9W.png

6-I added the middleware of the routes: https://i.imgur.com/O3n6R2P.png

7-I added in the uses of the model the dependence of Landlord: https://i.imgur.com/J9zRt6g.png

However, it does not filter the records according to the company: https://i.imgur.com/iSr8eKt.png

If I think to print the current tenant, you will see that the value of it is different from the value of the service that is returned: https://i.imgur.com/ve5mtee.png

The strange thing is that I configured the landlord last week in another project and if I'm not mistaken, I performed exactly the same steps, however, the project was Laravel 5.4

If anyone has any suggestions, please tell me.

gustavonecore commented 6 years ago

@jackrsantana I had the same issue, and the problem is that you are using the key company_id in your middleware as tenant_id name, but the default app/config/landlord.php file uses tenant_id as key. Make the change to match both setups and should work ok.