diff --git a/backend/app/Models/PlaceMunicipality.php b/backend/app/Models/PlaceMunicipality.php new file mode 100644 index 0000000..5ced434 --- /dev/null +++ b/backend/app/Models/PlaceMunicipality.php @@ -0,0 +1,32 @@ + + */ + protected $fillable = [ + 'code', 'name', 'foreign_name', 'cadastral_code', 'postal_code', 'prefix', 'email', 'pec', 'phone', 'fax', 'latitude', 'longitude' + ]; + + /** + * Get the province + */ + public function province(): BelongsTo + { + return $this->belongsTo(PlaceProvince::class); + } +} diff --git a/backend/app/Models/PlaceProvince.php b/backend/app/Models/PlaceProvince.php new file mode 100644 index 0000000..251a768 --- /dev/null +++ b/backend/app/Models/PlaceProvince.php @@ -0,0 +1,17 @@ +id(); + $table->string('code', 2)->unique(); + $table->string('name', 100); + $table->string('short_name', 2); + $table->string('region', 25); + }); + Schema::create('PlaceMunicipality', function (Blueprint $table) { + $table->id(); + $table->string('code', 6)->unique(); + $table->string('name', 200); + $table->string('foreign_name', 200)->nullable(); + $table->string('cadastral_code', 4)->nullable(); + $table->string('postal_code', 5)->nullable(); + $table->string('prefix', 4)->nullable(); + $table->string('email', 200)->nullable(); + $table->string('pec', 200)->nullable(); + $table->string('phone', 30)->nullable(); + $table->string('fax', 30)->nullable(); + $table->decimal('latitude', 10, 8)->nullable(); + $table->decimal('longitude', 11, 8)->nullable(); + $table->foreignId('province_id')->constrained('PlaceProvince'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('PlaceMunicipality'); + Schema::dropIfExists('PlaceProvince'); + } +};