Closed nam-co closed 2 years ago
@nam-co Yes you can, you need to change your shop_auth_provider
to shops
and add your new shop provider to config/auth.php like so:
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
'shops' => [
'driver' => 'eloquent',
'model' => App\Models\Shop::class,
],
],
Make the Shop model, copy the user class and make it implement the same stuff and same ids, you'll need manual migrations, and change everything that references user to shop. Calling Auth::user()
can return a shop or a user, depending on your context
Decent solution provided so closing ticket.
@CetoBasilius Sorry about this, I didn't see the answer before, appreciate the help Im going to give it a try, thank you
@CetoBasilius @osiset sorry about this, but is there any way to include an extra field to be saved on the DB, for example biz_id, user_id or whatever_id?
@nam-co just add it to your migrations when you create the shop table, you can just add whatever id you want when you create the table. Then in your user class, just create a relationship to the Shop table so you can access it via eloquent if you like.
Hi @osiset I was wondering if it's possible to use another model instead of users? in a multiple staff scenario, where users belong to a company model, and the company is the one that needs access.
Also, (not important) for just 'read_products,read_product_listings' are all the migrations tables necessary ?
Appreciate any guidance, thanks for the work you put into the package