Skip to content

Support for HasUuids trait #423

Discussion options

You must be logged in to vote

Hi!

Is there a reason you have both an id and uuid column? Here's how I'd set it up:

// app/Models/Account
class Account extends Projection
{
    use HasUuids;

    protected $guarded = [];

    public static function createWithAttributes(array $attributes): Account
    {
        $attributes['id'] = (string) Uuid::uuid4();

        event(new AccountCreated($attributes));

        return static::find($attributes['uuid']);
    }
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAccountsTable extends Migration
{
    public function up()
    {
        Schema::create('accounts', function (Blueprint $table)…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@morpheus7CS
Comment options

Answer selected by sebastiandedeyne
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants