@@ -12,17 +12,17 @@ |
||
12 | 12 | public function boot() |
13 | 13 | { |
14 | 14 | collect(glob(__DIR__ . '/Database/Schema/macros/*.php')) |
15 | - ->each(function ($path) { |
|
15 | + ->each(function($path) { |
|
16 | 16 | require $path; |
17 | 17 | }); |
18 | 18 | |
19 | 19 | /* A little hack to have Builder::hasMacro */ |
20 | - \Illuminate\Database\Eloquent\Builder::macro('hasMacro', function ($name) { |
|
20 | + \Illuminate\Database\Eloquent\Builder::macro('hasMacro', function($name) { |
|
21 | 21 | return isset(static::$macros[$name]); |
22 | 22 | }); |
23 | 23 | |
24 | 24 | collect(glob(__DIR__ . '/Models/macros/*.php')) |
25 | - ->each(function ($path) { |
|
25 | + ->each(function($path) { |
|
26 | 26 | require $path; |
27 | 27 | }); |
28 | 28 | } |
@@ -2,6 +2,6 @@ |
||
2 | 2 | |
3 | 3 | use Illuminate\Database\Eloquent\Builder; |
4 | 4 | |
5 | -Builder::macro('user', function ($value) { |
|
5 | +Builder::macro('user', function($value) { |
|
6 | 6 | return $this->where('user_id', $value); |
7 | 7 | }); |
@@ -2,18 +2,18 @@ |
||
2 | 2 | |
3 | 3 | use Illuminate\Database\Eloquent\Builder; |
4 | 4 | |
5 | -Builder::macro('status', function ($status, $key = 'status') { |
|
5 | +Builder::macro('status', function($status, $key = 'status') { |
|
6 | 6 | return $this->where($key, $status); |
7 | 7 | }); |
8 | 8 | |
9 | -Builder::macro('is', function ($key, $value = true, $prefix = 'is_') { |
|
9 | +Builder::macro('is', function($key, $value = true, $prefix = 'is_') { |
|
10 | 10 | return $this->where($prefix . $key, $value); |
11 | 11 | }); |
12 | 12 | |
13 | -Builder::macro('at', function ($key, $value, $suffix = '_at') { |
|
13 | +Builder::macro('at', function($key, $value, $suffix = '_at') { |
|
14 | 14 | return $this->where($key . $suffix, $value); |
15 | 15 | }); |
16 | 16 | |
17 | -Builder::macro('by', function ($key, $value, $suffix = '_by') { |
|
17 | +Builder::macro('by', function($key, $value, $suffix = '_by') { |
|
18 | 18 | return $this->where($key . $suffix, $value); |
19 | 19 | }); |
@@ -2,18 +2,18 @@ |
||
2 | 2 | |
3 | 3 | use Illuminate\Database\Eloquent\Builder; |
4 | 4 | |
5 | -Builder::macro('label', function ($label, $key = 'label') { |
|
5 | +Builder::macro('label', function($label, $key = 'label') { |
|
6 | 6 | return $this->where($key, $label); |
7 | 7 | }); |
8 | 8 | |
9 | -Builder::macro('name', function ($name, $key = 'name') { |
|
9 | +Builder::macro('name', function($name, $key = 'name') { |
|
10 | 10 | return $this->where($key, $name); |
11 | 11 | }); |
12 | 12 | |
13 | -Builder::macro('code', function ($code, $key = 'code') { |
|
13 | +Builder::macro('code', function($code, $key = 'code') { |
|
14 | 14 | return $this->where($code, $code); |
15 | 15 | }); |
16 | 16 | |
17 | -Builder::macro('reference', function ($reference, $key = 'reference') { |
|
17 | +Builder::macro('reference', function($reference, $key = 'reference') { |
|
18 | 18 | return $this->where($key, $reference); |
19 | 19 | }); |
@@ -2,34 +2,34 @@ |
||
2 | 2 | |
3 | 3 | use Illuminate\Database\Eloquent\Builder; |
4 | 4 | |
5 | -Builder::macro('uuid', function ($uuid) { |
|
5 | +Builder::macro('uuid', function($uuid) { |
|
6 | 6 | return $this->where('uuid', $uuid); |
7 | 7 | }); |
8 | 8 | |
9 | -Builder::macro('findByUuid', function ($uuid) { |
|
9 | +Builder::macro('findByUuid', function($uuid) { |
|
10 | 10 | return $this->uuid($uuid)->firstOrFail(); |
11 | 11 | }); |
12 | 12 | |
13 | -Builder::macro('hashslug', function ($hashslug) { |
|
13 | +Builder::macro('hashslug', function($hashslug) { |
|
14 | 14 | return $this->where('hashslug', $hashslug); |
15 | 15 | }); |
16 | 16 | |
17 | -Builder::macro('findByHashSlug', function ($hashslug) { |
|
17 | +Builder::macro('findByHashSlug', function($hashslug) { |
|
18 | 18 | return $this->hashslug($hashslug)->firstOrFail(); |
19 | 19 | }); |
20 | 20 | |
21 | -Builder::macro('hashslugOrId', function ($identifier) { |
|
21 | +Builder::macro('hashslugOrId', function($identifier) { |
|
22 | 22 | return $this->hashslug($identifier)->orWhere('id', $identifier); |
23 | 23 | }); |
24 | 24 | |
25 | -Builder::macro('findByHashSlugOrId', function ($identifier) { |
|
25 | +Builder::macro('findByHashSlugOrId', function($identifier) { |
|
26 | 26 | return $this->hashslugOrId($identifier)->firstOrFail(); |
27 | 27 | }); |
28 | 28 | |
29 | -Builder::macro('slug', function ($slug) { |
|
29 | +Builder::macro('slug', function($slug) { |
|
30 | 30 | return $this->where('slug', $slug); |
31 | 31 | }); |
32 | 32 | |
33 | -Builder::macro('findBySlug', function ($slug) { |
|
33 | +Builder::macro('findBySlug', function($slug) { |
|
34 | 34 | return $this->slug($slug)->firstOrFail(); |
35 | 35 | }); |
@@ -5,11 +5,11 @@ |
||
5 | 5 | /* |
6 | 6 | * Common Setup |
7 | 7 | */ |
8 | -Blueprint::macro('user', function ($nullable = false) { |
|
8 | +Blueprint::macro('user', function($nullable = false) { |
|
9 | 9 | return $this->addForeign('users', ['nullable' => $nullable])->comment('Owner of the record.'); |
10 | 10 | }); |
11 | 11 | |
12 | -Blueprint::macro('standardTime', function () { |
|
12 | +Blueprint::macro('standardTime', function() { |
|
13 | 13 | $this->softDeletes(); |
14 | 14 | $this->timestamps(); |
15 | 15 | }); |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | /* |
6 | 6 | * Acceptance |
7 | 7 | */ |
8 | -Blueprint::macro('addAcceptance', function ($value, $table_by = 'users', $is_default = true) { |
|
8 | +Blueprint::macro('addAcceptance', function($value, $table_by = 'users', $is_default = true) { |
|
9 | 9 | $this->is($value, $is_default); |
10 | 10 | $this->at($value); |
11 | 11 | $this->by($table_by, $value); |
@@ -14,21 +14,21 @@ discard block |
||
14 | 14 | return $this; |
15 | 15 | }); |
16 | 16 | |
17 | -Blueprint::macro('status', function ($key = 'status', $default = true) { |
|
17 | +Blueprint::macro('status', function($key = 'status', $default = true) { |
|
18 | 18 | return $this->boolean($key)->default($default)->comment('Status'); |
19 | 19 | }); |
20 | 20 | |
21 | -Blueprint::macro('is', function ($key = 'activated', $default = true, $prefix = 'is_') { |
|
21 | +Blueprint::macro('is', function($key = 'activated', $default = true, $prefix = 'is_') { |
|
22 | 22 | return $this->status($prefix . $key, $default)->comment('Is it ' . $key . '?'); |
23 | 23 | }); |
24 | 24 | |
25 | -Blueprint::macro('at', function ($key = 'activated', $suffix = '_at') { |
|
25 | +Blueprint::macro('at', function($key = 'activated', $suffix = '_at') { |
|
26 | 26 | return $this->datetime($key . $suffix)->nullable()->comment('Event occured at Date & Time'); |
27 | 27 | }); |
28 | 28 | |
29 | -Blueprint::macro('by', function ($table, $key = null, $nullable = true, $bigInteger = false, $suffix = '_by') { |
|
29 | +Blueprint::macro('by', function($table, $key = null, $nullable = true, $bigInteger = false, $suffix = '_by') { |
|
30 | 30 | return $this->addForeign($table, [ |
31 | - 'fk' => (! is_null($key) ? $key . $suffix : null), |
|
31 | + 'fk' => ( ! is_null($key) ? $key . $suffix : null), |
|
32 | 32 | 'nullable' => $nullable, |
33 | 33 | 'bigInteger' => $bigInteger, |
34 | 34 | ]); |
@@ -3,16 +3,16 @@ |
||
3 | 3 | use Illuminate\Database\Schema\Blueprint; |
4 | 4 | |
5 | 5 | // will be deprecated |
6 | -Blueprint::macro('actedStatus', function ($value = 'is_acted') { |
|
6 | +Blueprint::macro('actedStatus', function($value = 'is_acted') { |
|
7 | 7 | return $this->boolean($value)->default(false)->comment('Action statys in Boolean'); |
8 | 8 | }); |
9 | 9 | |
10 | 10 | // will be deprecated |
11 | -Blueprint::macro('actedAt', function ($value = 'acted_at') { |
|
11 | +Blueprint::macro('actedAt', function($value = 'acted_at') { |
|
12 | 12 | return $this->datetime($value)->nullable()->comment('Acted at Date & Time'); |
13 | 13 | }); |
14 | 14 | |
15 | 15 | // will be deprecated |
16 | -Blueprint::macro('actedBy', function ($value = 'acted_by') { |
|
16 | +Blueprint::macro('actedBy', function($value = 'acted_by') { |
|
17 | 17 | return $this->unsignedInteger($value)->nullable()->comment('Done / Acted by an actor'); |
18 | 18 | }); |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | /* |
8 | 8 | * Create an index if it doesn't exist yet |
9 | 9 | */ |
10 | -Blueprint::macro('createIndexIfNotExists', function ($columns, $name = null, $connection = null) { |
|
10 | +Blueprint::macro('createIndexIfNotExists', function($columns, $name = null, $connection = null) { |
|
11 | 11 | return $this->hasIndex($columns, $connection) |
12 | 12 | ? $this |
13 | 13 | : $this->index($columns, $name ?: $this->createIndexNameByColumns($columns)); |
@@ -16,21 +16,21 @@ discard block |
||
16 | 16 | /* |
17 | 17 | * Check if an index exists |
18 | 18 | */ |
19 | -Blueprint::macro('hasIndex', function ($columns) { |
|
19 | +Blueprint::macro('hasIndex', function($columns) { |
|
20 | 20 | return $this->getIndexNameByColumns($columns) !== null; |
21 | 21 | }); |
22 | 22 | |
23 | 23 | /* |
24 | 24 | * Get an index name by columns |
25 | 25 | */ |
26 | -Blueprint::macro('getIndexNameByColumns', function ($columns) { |
|
26 | +Blueprint::macro('getIndexNameByColumns', function($columns) { |
|
27 | 27 | if (is_string($columns)) { |
28 | 28 | $columns = [$columns]; |
29 | 29 | } |
30 | 30 | |
31 | 31 | $schemaManager = Schema::getConnection()->getDoctrineSchemaManager(); |
32 | 32 | $indices = $schemaManager->listTableIndexes($this->getTable()); |
33 | - $filteredIndices = collect($indices)->filter(function (Index $index) use ($columns) { |
|
33 | + $filteredIndices = collect($indices)->filter(function(Index $index) use ($columns) { |
|
34 | 34 | return compare_array($index->getColumns(), $columns); |
35 | 35 | }); |
36 | 36 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | /* |
45 | 45 | * Create an index name based on columns |
46 | 46 | */ |
47 | -Blueprint::macro('createIndexNameByColumns', function ($columns) { |
|
47 | +Blueprint::macro('createIndexNameByColumns', function($columns) { |
|
48 | 48 | if (is_string($columns)) { |
49 | 49 | $columns = [$columns]; |
50 | 50 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | /* |
62 | 62 | * Drop an index if it exists |
63 | 63 | */ |
64 | -Blueprint::macro('dropIndexIfExists', function ($columns) { |
|
64 | +Blueprint::macro('dropIndexIfExists', function($columns) { |
|
65 | 65 | if ($this->hasIndex($columns)) { |
66 | 66 | return $this->dropIndex($this->getIndexNameByColumns($columns)); |
67 | 67 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | return $this; |
70 | 70 | }); |
71 | 71 | |
72 | -if (! function_exists('compare_array')) { |
|
72 | +if ( ! function_exists('compare_array')) { |
|
73 | 73 | /** |
74 | 74 | * @param $arrayA |
75 | 75 | * @param $arrayB |