1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 19:14:04 +00:00

HasScopedValidationRules trait

This commit is contained in:
Samuel Štancl 2020-05-14 05:13:33 +02:00
parent 208eb2fdd3
commit d92277a236
2 changed files with 69 additions and 1 deletions

View file

@ -0,0 +1,19 @@
<?php
namespace Stancl\Tenancy\Database\Concerns;
use Illuminate\Validation\Rules\Exists;
use Illuminate\Validation\Rules\Unique;
trait HasScopedValidationRules
{
public function unique($table, $column = 'NULL')
{
return (new Unique($table, $column))->where(BelongsToTenant::$tenantIdColumn, $this->getTenantKey());
}
public function exists($table, $column = 'NULL')
{
return (new Exists($table, $column))->where(BelongsToTenant::$tenantIdColumn, $this->getTenantKey());
}
}