File: /var/www/ipsremont-demo/database/migrations/2021_01_20_164959_create_address_table.php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAddressTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('address', function (Blueprint $table) {
$table->id();
$table->string('name')->comment('Название');
$table->string('country')->comment('Страна');
$table->string('city')->comment('Город');
$table->string('address')->comment('Адрес');
$table->string('email')->comment('Email')->nullable();
$table->string('phone')->comment('Телефон')->nullable();
$table->boolean('main')->comment('Основной')->default(0);
$table->unsignedBigInteger('service_id');
$table->unsignedBigInteger('user_id');
$table->softDeletes();
$table->timestamp('created_at')->nullable()->useCurrent();
$table->timestamp('updated_at')->nullable()->useCurrent();
$table->foreign('service_id')->references('id')->on('services')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('address');
}
}