@@ -21,14 +21,12 @@ discard block |
||
| 21 | 21 | /* |
| 22 | 22 | * Foreign Key |
| 23 | 23 | */ |
| 24 | - DefaultBlueprint::macro('addForeign', function ($table, $options = []) { |
|
| 24 | + DefaultBlueprint::macro('addForeign', function($table, $options = []) { |
|
| 25 | 25 | $fk = (isset($options['fk']) && ! empty($options['fk'])) ? |
| 26 | - $options['fk'] : |
|
| 27 | - Str::lower(Str::singular($table)) . '_id'; |
|
| 26 | + $options['fk'] : Str::lower(Str::singular($table)) . '_id'; |
|
| 28 | 27 | |
| 29 | 28 | $reference = (isset($options['reference']) && ! empty($options['reference'])) ? |
| 30 | - $options['reference'] : |
|
| 31 | - 'id'; |
|
| 29 | + $options['reference'] : 'id'; |
|
| 32 | 30 | |
| 33 | 31 | if (isset($options['bigInteger']) && true == $options['bigInteger']) { |
| 34 | 32 | $schema = $this->unsignedBigInteger($fk)->index(); |
@@ -40,24 +38,24 @@ discard block |
||
| 40 | 38 | $schema->nullable(); |
| 41 | 39 | } |
| 42 | 40 | |
| 43 | - if (! isset($options['no_reference'])) { |
|
| 41 | + if ( ! isset($options['no_reference'])) { |
|
| 44 | 42 | $this->referenceOn($fk, $table, $reference); |
| 45 | 43 | } |
| 46 | 44 | |
| 47 | 45 | return $schema; |
| 48 | 46 | }); |
| 49 | 47 | |
| 50 | - DefaultBlueprint::macro('addNullableForeign', function ($table, $fk, $bigInteger = false) { |
|
| 48 | + DefaultBlueprint::macro('addNullableForeign', function($table, $fk, $bigInteger = false) { |
|
| 51 | 49 | return $this->addForeign($table, ['nullable' => true, 'fk' => $fk, 'bigInteger' => $bigInteger]); |
| 52 | 50 | }); |
| 53 | 51 | |
| 54 | - DefaultBlueprint::macro('referenceOn', function ($key, $table, $reference = 'id') { |
|
| 52 | + DefaultBlueprint::macro('referenceOn', function($key, $table, $reference = 'id') { |
|
| 55 | 53 | return $this->foreign($key) |
| 56 | 54 | ->references($reference) |
| 57 | 55 | ->on($table); |
| 58 | 56 | }); |
| 59 | 57 | |
| 60 | - DefaultBlueprint::macro('belongsTo', function ($table, $key = null, $bigInteger = false, $reference = 'id') { |
|
| 58 | + DefaultBlueprint::macro('belongsTo', function($table, $key = null, $bigInteger = false, $reference = 'id') { |
|
| 61 | 59 | if (is_null($key)) { |
| 62 | 60 | $key = Str::lower(Str::singular($table)) . '_id'; |
| 63 | 61 | } |
@@ -65,7 +63,7 @@ discard block |
||
| 65 | 63 | return $this->addForeign($table, ['fk' => $key, 'reference' => $reference, 'bigInteger' => $bigInteger]); |
| 66 | 64 | }); |
| 67 | 65 | |
| 68 | - DefaultBlueprint::macro('nullableBelongsTo', function ($table, $key = null, $bigInteger = false, $reference = 'id') { |
|
| 66 | + DefaultBlueprint::macro('nullableBelongsTo', function($table, $key = null, $bigInteger = false, $reference = 'id') { |
|
| 69 | 67 | if (is_null($key)) { |
| 70 | 68 | $key = Str::lower(Str::singular($table)) . '_id'; |
| 71 | 69 | } |
@@ -76,11 +74,11 @@ discard block |
||
| 76 | 74 | /* |
| 77 | 75 | * Common Setup |
| 78 | 76 | */ |
| 79 | - DefaultBlueprint::macro('user', function ($nullable = false) { |
|
| 77 | + DefaultBlueprint::macro('user', function($nullable = false) { |
|
| 80 | 78 | return $this->addForeign('users', ['nullable' => $nullable]); |
| 81 | 79 | }); |
| 82 | 80 | |
| 83 | - DefaultBlueprint::macro('standardTime', function () { |
|
| 81 | + DefaultBlueprint::macro('standardTime', function() { |
|
| 84 | 82 | $this->softDeletes(); |
| 85 | 83 | $this->timestamps(); |
| 86 | 84 | }); |
@@ -88,11 +86,11 @@ discard block |
||
| 88 | 86 | /* |
| 89 | 87 | * Identifier Replacement |
| 90 | 88 | */ |
| 91 | - DefaultBlueprint::macro('uuid', function ($length = 64) { |
|
| 89 | + DefaultBlueprint::macro('uuid', function($length = 64) { |
|
| 92 | 90 | return $this->string('uuid', $length); |
| 93 | 91 | }); |
| 94 | 92 | |
| 95 | - DefaultBlueprint::macro('hashslug', function ($length = 64) { |
|
| 93 | + DefaultBlueprint::macro('hashslug', function($length = 64) { |
|
| 96 | 94 | return $this->string('hashslug') |
| 97 | 95 | ->length($length) |
| 98 | 96 | ->nullable() |
@@ -100,7 +98,7 @@ discard block |
||
| 100 | 98 | ->index(); |
| 101 | 99 | }); |
| 102 | 100 | |
| 103 | - DefaultBlueprint::macro('slug', function () { |
|
| 101 | + DefaultBlueprint::macro('slug', function() { |
|
| 104 | 102 | return $this->string('slug') |
| 105 | 103 | ->nullable() |
| 106 | 104 | ->unique() |
@@ -110,22 +108,22 @@ discard block |
||
| 110 | 108 | /* |
| 111 | 109 | * Short String |
| 112 | 110 | */ |
| 113 | - DefaultBlueprint::macro('label', function ($value = 'label', $length = 255) { |
|
| 111 | + DefaultBlueprint::macro('label', function($value = 'label', $length = 255) { |
|
| 114 | 112 | return $this->string($value, $length)->nullable(); |
| 115 | 113 | }); |
| 116 | 114 | |
| 117 | - DefaultBlueprint::macro('name', function ($value = 'name', $length = 255) { |
|
| 115 | + DefaultBlueprint::macro('name', function($value = 'name', $length = 255) { |
|
| 118 | 116 | return $this->string($value, $length)->nullable(); |
| 119 | 117 | }); |
| 120 | 118 | |
| 121 | - DefaultBlueprint::macro('code', function ($key = 'code', $length = 20) { |
|
| 119 | + DefaultBlueprint::macro('code', function($key = 'code', $length = 20) { |
|
| 122 | 120 | return $this->string($key, $length) |
| 123 | 121 | ->nullable() |
| 124 | 122 | ->unique() |
| 125 | 123 | ->index(); |
| 126 | 124 | }); |
| 127 | 125 | |
| 128 | - DefaultBlueprint::macro('reference', function ($label = 'reference', $length = 64) { |
|
| 126 | + DefaultBlueprint::macro('reference', function($label = 'reference', $length = 64) { |
|
| 129 | 127 | return $this->string('reference', $length) |
| 130 | 128 | ->nullable() |
| 131 | 129 | ->unique() |
@@ -135,18 +133,18 @@ discard block |
||
| 135 | 133 | /* |
| 136 | 134 | * Long String |
| 137 | 135 | */ |
| 138 | - DefaultBlueprint::macro('remarks', function ($value = 'remarks') { |
|
| 136 | + DefaultBlueprint::macro('remarks', function($value = 'remarks') { |
|
| 139 | 137 | return $this->text($value)->nullable(); |
| 140 | 138 | }); |
| 141 | 139 | |
| 142 | - DefaultBlueprint::macro('description', function ($label = 'description') { |
|
| 140 | + DefaultBlueprint::macro('description', function($label = 'description') { |
|
| 143 | 141 | return $this->text($label)->nullable(); |
| 144 | 142 | }); |
| 145 | 143 | |
| 146 | 144 | /* |
| 147 | 145 | * Acceptance |
| 148 | 146 | */ |
| 149 | - DefaultBlueprint::macro('addAcceptance', function ($value, $table_by = 'users') { |
|
| 147 | + DefaultBlueprint::macro('addAcceptance', function($value, $table_by = 'users') { |
|
| 150 | 148 | $this->is($value); |
| 151 | 149 | $this->at($value); |
| 152 | 150 | $this->by($table_by, $value); |
@@ -155,51 +153,51 @@ discard block |
||
| 155 | 153 | return $this; |
| 156 | 154 | }); |
| 157 | 155 | |
| 158 | - DefaultBlueprint::macro('status', function ($key = 'status', $default = true) { |
|
| 156 | + DefaultBlueprint::macro('status', function($key = 'status', $default = true) { |
|
| 159 | 157 | return $this->boolean($key)->default($default); |
| 160 | 158 | }); |
| 161 | 159 | |
| 162 | - DefaultBlueprint::macro('is', function ($key = 'activated', $default = true, $prefix = 'is_') { |
|
| 160 | + DefaultBlueprint::macro('is', function($key = 'activated', $default = true, $prefix = 'is_') { |
|
| 163 | 161 | return $this->status($prefix . $key, $default); |
| 164 | 162 | }); |
| 165 | 163 | |
| 166 | - DefaultBlueprint::macro('at', function ($key = 'activated', $suffix = '_at') { |
|
| 164 | + DefaultBlueprint::macro('at', function($key = 'activated', $suffix = '_at') { |
|
| 167 | 165 | return $this->datetime($key . $suffix)->nullable(); |
| 168 | 166 | }); |
| 169 | 167 | |
| 170 | - DefaultBlueprint::macro('by', function ($table, $key = null, $nullable = true, $bigInteger = false, $suffix = '_by') { |
|
| 168 | + DefaultBlueprint::macro('by', function($table, $key = null, $nullable = true, $bigInteger = false, $suffix = '_by') { |
|
| 171 | 169 | return $this->addForeign($table, [ |
| 172 | - 'fk' => (! is_null($key) ? $key . $suffix : null), |
|
| 170 | + 'fk' => ( ! is_null($key) ? $key . $suffix : null), |
|
| 173 | 171 | 'nullable' => $nullable, |
| 174 | 172 | 'bigInteger' => $bigInteger, |
| 175 | 173 | ]); |
| 176 | 174 | }); |
| 177 | 175 | |
| 178 | 176 | // will be deprecated |
| 179 | - DefaultBlueprint::macro('actedStatus', function ($value = 'is_acted') { |
|
| 177 | + DefaultBlueprint::macro('actedStatus', function($value = 'is_acted') { |
|
| 180 | 178 | return $this->boolean($value)->default(false); |
| 181 | 179 | }); |
| 182 | 180 | |
| 183 | 181 | // will be deprecated |
| 184 | - DefaultBlueprint::macro('actedAt', function ($value = 'acted_at') { |
|
| 182 | + DefaultBlueprint::macro('actedAt', function($value = 'acted_at') { |
|
| 185 | 183 | return $this->datetime($value)->nullable(); |
| 186 | 184 | }); |
| 187 | 185 | |
| 188 | 186 | // will be deprecated |
| 189 | - DefaultBlueprint::macro('actedBy', function ($value = 'acted_by') { |
|
| 187 | + DefaultBlueprint::macro('actedBy', function($value = 'acted_by') { |
|
| 190 | 188 | return $this->unsignedInteger($value)->nullable(); |
| 191 | 189 | }); |
| 192 | 190 | |
| 193 | 191 | /* |
| 194 | 192 | * Money |
| 195 | 193 | */ |
| 196 | - DefaultBlueprint::macro('amount', function ($label = 'amount') { |
|
| 194 | + DefaultBlueprint::macro('amount', function($label = 'amount') { |
|
| 197 | 195 | return $this->bigInteger($label) |
| 198 | 196 | ->nullable() |
| 199 | 197 | ->default(0); |
| 200 | 198 | }); |
| 201 | 199 | |
| 202 | - DefaultBlueprint::macro('smallAmount', function ($label = 'amount') { |
|
| 200 | + DefaultBlueprint::macro('smallAmount', function($label = 'amount') { |
|
| 203 | 201 | return $this->integer($label) |
| 204 | 202 | ->nullable() |
| 205 | 203 | ->default(0); |
@@ -208,16 +206,16 @@ discard block |
||
| 208 | 206 | /* |
| 209 | 207 | * Misc. |
| 210 | 208 | */ |
| 211 | - DefaultBlueprint::macro('ordering', function ($key = 'ordering', $length = 10) { |
|
| 209 | + DefaultBlueprint::macro('ordering', function($key = 'ordering', $length = 10) { |
|
| 212 | 210 | return $this->string($key, $length) |
| 213 | 211 | ->nullable(); |
| 214 | 212 | }); |
| 215 | 213 | |
| 216 | - DefaultBlueprint::macro('percent', function ($key = 'percent') { |
|
| 214 | + DefaultBlueprint::macro('percent', function($key = 'percent') { |
|
| 217 | 215 | return $this->decimal($key, 5, 2)->default(0); |
| 218 | 216 | }); |
| 219 | 217 | |
| 220 | - DefaultBlueprint::macro('expired', function () { |
|
| 218 | + DefaultBlueprint::macro('expired', function() { |
|
| 221 | 219 | $this->boolean('is_expired')->default(false); |
| 222 | 220 | $this->datetime('expired_at')->nullable(); |
| 223 | 221 | |