Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Fetch a key from an array
<?php key(array|object $array): int|string|null
<?php $modifiers = collect($modifiers)->reject(
fn ($modifier) => (is_array($modifier) && key($modifier) === 'foreign')
|| (is_array($modifier) && key($modifier) === 'onDelete')
|| (is_array($modifier) && key($modifier) === 'onUpdate')
|| $modifier === 'foreign'
<?php $modifiers = collect($modifiers)->reject(
fn ($modifier) => (is_array($modifier) && key($modifier) === 'foreign')
|| (is_array($modifier) && key($modifier) === 'onDelete')
|| (is_array($modifier) && key($modifier) === 'onUpdate')
|| $modifier === 'foreign'
|| ($modifier === 'nullable' && $this->isIdOrUuid($column->dataType()))
<?php $modifiers = collect($modifiers)->reject(
fn ($modifier) => (is_array($modifier) && key($modifier) === 'foreign')
|| (is_array($modifier) && key($modifier) === 'onDelete')
|| (is_array($modifier) && key($modifier) === 'onUpdate')
|| $modifier === 'foreign'
|| ($modifier === 'nullable' && $this->isIdOrUuid($column->dataType()))
);
<?php foreach ($modifiers as $modifier) {
if (is_array($modifier)) {
$modifierKey = key($modifier);
$modifierValue = addslashes(current($modifier));
if ($modifierKey === 'default' && ($modifierValue === 'null' || $dataType === 'boolean' || $this->isNumericDefault($dataType, $modifierValue))) {
$column_definition .= sprintf('->%s(%s)', $modifierKey, $modifierValue);
<?php if (isset($columns['indexes'])) {
foreach ($columns['indexes'] as $index) {
$model->addIndex(new Index(key($index), array_map('trim', explode(',', current($index)))));
}
unset($columns['indexes']);
}
<?php }
if (is_null($data_type)) {
$is_foreign_key = collect($modifiers)->contains(fn ($modifier) => (is_array($modifier) && key($modifier) === 'foreign') || $modifier === 'foreign');
$data_type = $is_foreign_key ? 'id' : 'string';
}
<?php public function isForeignKey()
{
return collect($this->modifiers())->filter(fn ($modifier) => (is_array($modifier) && key($modifier) === 'foreign') || $modifier === 'foreign')->flatten()->first();
}
public function defaultValue()