Cannot scoping based on tenants
Closed this issue · 4 comments
I cannot scoping category by tenant with param injection, code like this
routes/web.php
Route::group(['middleware' => ['tenant.guest']], function () {
Route::get('/show/{category}', 'CategoryController@show');
});
and on App/Controller/CategoryController.php
public function show(Category $category)
{
return $category;
}
on model App/Models/Category.php
class Category extends Model
{
use BelongsToTenant;
}
Is there an error in my code? Or there is an idea for this
But this seems different. If I throw a parameter with {id} category and I take it with eloquent find(). It goes well scoping by tenants.
Which is a problem if I throw in the {category} parameter, and I immediately return it won't go to the scope.
Could you show some code examples?
this is not work
routes/web.php
Route::group(['middleware' => ['tenant.guest']], function () {
Route::get('/show/{category}', 'CategoryController@show');
});
and on App/Controller/CategoryController.php
public function show(Category $category)
{
return $category;
}
on model App/Models/Category.php
class Category extends Model
{
use BelongsToTenant;
}
this is work well
routes/web.php
Route::group(['middleware' => ['tenant.guest']], function () {
Route::get('/show/{id}', 'CategoryController@show');
});
and on App/Controller/CategoryController.php
public function show($id)
{
return Category::find($id);
}
on model App/Models/Category.php
class Category extends Model
{
use BelongsToTenant;
}
the code above if I throw the {id} category parameter that does not belong to tenant, it will not return the results. It is true
different if I throw the {category} parameter, if I throw a parameter that does not belong to tenant, it will still be return the results. I think the global scope of the belongsToTenant it isn't going well.