Merge pull request #4 from kaiser-software/feature/add-after-support-for-blueprint-macros
Added after column support for blueprint macro
This commit is contained in:
commit
921f1df2ad
|
|
@ -11,7 +11,7 @@ class Blueprint
|
||||||
{
|
{
|
||||||
public function encrypted(): Closure
|
public function encrypted(): Closure
|
||||||
{
|
{
|
||||||
return function (string $name, ?array $indexes = null): void {
|
return function (string $name, ?array $indexes = null, ?string $after = null, bool $nullable = false): void {
|
||||||
$columns = empty($indexes)
|
$columns = empty($indexes)
|
||||||
? [
|
? [
|
||||||
$name,
|
$name,
|
||||||
|
|
@ -23,7 +23,13 @@ class Blueprint
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($columns as $column) {
|
foreach ($columns as $column) {
|
||||||
$this->string($column);
|
$addedColumn = $this->string($column)->nullable($nullable);
|
||||||
|
|
||||||
|
if($after) {
|
||||||
|
$addedColumn->after($after);
|
||||||
|
|
||||||
|
$after = $column;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->index($columns);
|
$this->index($columns);
|
||||||
|
|
@ -32,22 +38,8 @@ class Blueprint
|
||||||
|
|
||||||
public function nullableEncrypted(): Closure
|
public function nullableEncrypted(): Closure
|
||||||
{
|
{
|
||||||
return function (string $name, ?array $indexes = null): void {
|
return function (string $name, ?array $indexes = null, ?string $after = null): void {
|
||||||
$columns = empty($indexes)
|
$this->encrypted($name, $indexes, $after, true);
|
||||||
? [
|
|
||||||
$name,
|
|
||||||
"{$name}_index",
|
|
||||||
]
|
|
||||||
: array_merge(
|
|
||||||
[$name],
|
|
||||||
$indexes
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($columns as $column) {
|
|
||||||
$this->string($column)->nullable();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->index($columns);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue