mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 19:14:04 +00:00
HasScopedValidationRules trait
This commit is contained in:
parent
208eb2fdd3
commit
d92277a236
2 changed files with 69 additions and 1 deletions
19
src/Database/Concerns/HasScopedValidationRules.php
Normal file
19
src/Database/Concerns/HasScopedValidationRules.php
Normal 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());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue