for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace TopviewDigital\UniqueJsonRule;
class UniqueJsonRule
{
/**
* @var string
*/
protected $rule = 'unique_json';
protected $table;
* @var string|null
protected $column = null;
* @var mixed
protected $ignoreValue = null;
protected $ignoreColumn = null;
* Create a new rule instance.
*
* @param string $table
* @param string|null $column
* @return static
public static function for($table, $column = null)
return new static($table, $column);
}
public function __construct($table, $column = null)
$this->table = $table;
$this->column = $column;
* Ignore any record that has a column with the given value.
* @param mixed $value
* @param string $column
* @return $this
public function ignore($value, $column = 'id')
$this->ignoreValue = $value;
$this->ignoreColumn = $column;
return $this;
* Generate a string representation of the validation rule.
* @return string
public function __toString()
return sprintf(
'%s:%s,%s,%s,%s',
$this->rule,
$this->table,
$this->column ?: 'NULL',
$this->ignoreValue ?: 'NULL',
$this->ignoreColumn ?: 'NULL'
);