省市区数据
parent
8f54ffc9e4
commit
21a8732860
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Zone extends Model
|
||||
{
|
||||
public const TYPE_PROVINCE = 'province';
|
||||
public const TYPE_CITY = 'city';
|
||||
public const TYPE_AREA = 'area';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'parent_id',
|
||||
'type',
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateZonesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('zones', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('parent_id')->nullable()->comment('父级 ID');
|
||||
$table->string('name')->comment('省/市/区 名称');
|
||||
$table->enum('type', ['province', 'city', 'area'])->comment('类型');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
DB::unprepared(file_get_contents(base_path('database/sql/zones.sql')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('zones');
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue