unsignedBigInteger('id'); $table->primary('id'); } public static function addCommonFields($table, array $params = []) { $table->timestamps(); self::treatParams($params); if (!$params['staticData']) { self::addDefaultFields($table, $params['foreignNames']); } } public static function addCommonFieldsWithSoftDeletes($table, array $params = []) { $table->timestamps(); $table->softDeletes(); self::treatParams($params); if (!$params['staticData']) { self::addDefaultFields($table, $params['foreignNames']); // Field: deleted_lotacao_id. $table->unsignedBigInteger('deleted_lotacao_id')->nullable(); $table->foreign('deleted_lotacao_id', $params['foreignNames']['deleted_lotacao_id'] ?? null) ->references('id')->on('cadastro_lotacao'); // Field: deleted_centro_custo_id. $table->unsignedBigInteger('deleted_centro_custo_id')->nullable(); $table->foreign('deleted_centro_custo_id', $params['foreignNames']['deleted_centro_custo_id'] ?? null) ->references('id')->on('cadastro_centro_custo'); } } private static function treatParams(&$params) { if (!isset($params['staticData'])) { $params['staticData'] = false; } if (!isset($params['foreignNames'])) { $params['foreignNames'] = []; } } private static function addDefaultFields($table, array $foreignNames) { // Field: created_lotacao_id. $table->unsignedBigInteger('created_lotacao_id')->nullable(); $table->foreign('created_lotacao_id', $foreignNames['created_lotacao_id'] ?? null) ->references('id')->on('cadastro_lotacao'); // Field: created_centro_custo_id. $table->unsignedBigInteger('created_centro_custo_id')->nullable(); $table->foreign('created_centro_custo_id', $foreignNames['created_centro_custo_id'] ?? null) ->references('id')->on('cadastro_centro_custo'); // Field: updated_lotacao_id. $table->unsignedBigInteger('updated_lotacao_id')->nullable(); $table->foreign('updated_lotacao_id', $foreignNames['updated_lotacao_id'] ?? null) ->references('id')->on('cadastro_lotacao'); // Field: updated_centro_custo_id. $table->unsignedBigInteger('updated_centro_custo_id')->nullable(); $table->foreign('updated_centro_custo_id', $foreignNames['updated_centro_custo_id'] ?? null) ->references('id')->on('cadastro_centro_custo'); } public static function dropColumnWithForeign($table, $field) { if (is_string($field)) { $field = [$field]; } $table->dropForeign($field); $table->dropColumn($field); } public static function addExternalFields($table) { $table->foreignId('externo_created_usuario_id')->nullable()->constrained('web_service_usuario'); $table->foreignId('externo_updated_usuario_id')->nullable()->constrained('web_service_usuario'); } }