Closed xyrintech closed 7 years ago
Please provide more context.
The tenant scope not getting applied. In a middleware I am applying tenant using addTenant method This is my table structure:
tenants id user_id
channels id tenant_id (reference from tenants table) name
In a controller to save Channel $this->validate($request, [ 'name' => 'required|unique:channels, name' ])
The tenant scope is not getting applied for this while checking the uniqueness of the data
Please copy and paste the code for the middleware and the channel model
Not sure if this is relevant, but i notice you have a space between "channels," and "name", might be related to the the problem if that causes the validator to think you want to check uniqueness for " name" column (that doesnt exist)... long short but worth a look.
Please ignore the typos in the code. Ideally in the channels table, name should be unique with tenant_id (i.e. composite keys)
Because multi tenants can have multiple channels. But this unique validation is not working as default if we use this package.
Unique validation is not working with tenant_id