Add PlaceMunicipality and PlaceProvince models and migration files
This commit is contained in:
parent
687d7613a0
commit
193710d14c
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use App\Models\PlaceProvince;
|
||||
|
||||
class PlaceMunicipality extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PlaceProvince extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'code', 'name', 'short_name', 'region'
|
||||
];
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('PlaceProvince', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue