1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 10:14:04 +00:00
tenancy/src/Database/Concerns/HasScopedValidationRules.php
2022-11-10 16:44:52 +01:00

22 lines
561 B
PHP

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