src/Lego/Field/Concerns/HasValidation.php
public function unique($id = null, $idColumn = null, $extra = null)
    {
        if (!$this->store instanceof \Lego\Operator\Eloquent\EloquentStore) {
            throw new LegoException(
                'Validation: `unique` rule only worked for Eloquent, ' .
                'you can use `validator($closure)` implement unique validation.'
            );
        }

        /**
         * @var \Illuminate\Database\Eloquent\Model
         * @var Field                               $this
         */
        $model = $this->data;

        $id = $id ?: $this->store->getKey() ?: 'NULL';
        $idColumn = $idColumn ?: $this->store->getKeyName();

        $parts = [
            "unique:{$model->getConnectionName()}.{$model->getTable()}",
            $this->column(),
            $id,
            $idColumn,
        ];

        if ($extra) {
            $parts[] = trim($extra, ',');
        }

        $this->rule(join(',', $parts));

        return $this;
    }
public function unique($id = null, $idColumn = null, $extra = null)
    {
        if (!$this->store instanceof \Lego\Operator\Eloquent\EloquentStore) {
            throw new LegoException(
                'Validation: `unique` rule only worked for Eloquent, ' .
                'you can use `validator($closure)` implement unique validation.'
            );
        }

        /**
         * @var \Illuminate\Database\Eloquent\Model
         * @var Field                               $this
         */
        $model = $this->data;

        $id = $id ?: $this->store->getKey() ?: 'NULL';
        $idColumn = $idColumn ?: $this->store->getKeyName();

        $parts = [
            "unique:{$model->getConnectionName()}.{$model->getTable()}",
            $this->column(),
            $id,
            $idColumn,
        ];

        if ($extra) {
            $parts[] = trim($extra, ',');
        }

        $this->rule(join(',', $parts));

        return $this;
    }
public function unique ( $ id = null , $ idColumn = null , $ extra = null ) { if ( ! $ this -> store instanceof \ Lego \ Operator \ Eloquent \ EloquentStore ) { throw new LegoException ( 'Validation: `unique` rule only worked for Eloquent, ' . 'you can use `validator($closure)` implement unique validation.' ) ; } /**
         * @var \Illuminate\Database\Eloquent\Model
         * @var Field                               $this
         */ $ model = $ this -> data ; $ id = $ id ? : $ this -> store -> getKey ( ) ? : 'NULL' ; $ idColumn = $ idColumn ? : $ this -> store -> getKeyName ( ) ; $ parts = [ "unique:{$model->getConnectionName()}.{$model->getTable()}" , $ this -> column ( ) , $ id , $ idColumn , ] ; if ( $ extra ) { $ parts [ ] = trim ( $ extra , ',' ) ; } $ this -> rule ( join ( ',' , $ parts ) ) ; return $ this ; }
Laravel Validation unique.

Auto except current model

https://laravel.com/docs/master/validation#rule-unique
Laravel Validation unique .