Laravel Tips

@Shoaib

1/2. UUID setup in migration.php

<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

class AddUuidExtensionToPostgresql extends Migration
{

public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->uuid('id')->primary() ->unique()->default(DB::raw('uuid_generate_v4()'));
}); DB::statement('CREATE EXTENSION IF NOT EXISTS "uuid-ossp";'); } public function down() { DB::statement('DROP EXTENSION IF EXISTS "uuid-ossp";'); } }