public function constraints($table)
{
$tableSchema = $table;
if (!$table instanceof Table) {
$tableSchema = $this->schema($table);
}
$constraints = [];
$tableConstraints = $tableSchema->constraints();
if (empty($tableConstraints)) {
return $constraints;
}
if ($tableConstraints[0] === 'primary') {
unset($tableConstraints[0]);
}
if (!empty($tableConstraints)) {
foreach ($tableConstraints as $name) {
$constraint = $tableSchema->constraint($name);
if (isset($constraint['update'])) {
$constraint['update'] = strtoupper(Inflector::underscore($constraint['update']));
$constraint['delete'] = strtoupper(Inflector::underscore($constraint['delete']));
}
$constraints[$name] = $constraint;
}
}
return $constraints;
}