YourAppRocks/eloquent-uuid

Class was composed in Model

rivassh opened this issue · 5 comments

when I'm testing in tinker:
use HasUuid;

protected $uuidColumnName = 'userid';
protected $uuidVersion = 1;    // Available 1,3,4 or 5
protected $uuidString  = '';   // Needed when $uuidVersion is "3 or 5"
protected $fillable = ['name', 'email', 'username', 'mobile', 'password', 'meta'];

migration:
Schema::create('subscribers', function (Blueprint $table) {
$table->uuid('userid')->primary();
tinker
Entities\Subscriber. However, the definition differs and is considered incompatible. Class was composed in /media/sf_media/h/opt/projects/Bodokar/Modules/Subscriber/Entities/Subscriber.php on line 8

In Subscriber.php line 8:

Modules\Subscriber\Entities\Subscriber and YourAppRocks\EloquentUuid\Traits\HasUuid define the same property ($uuidColumnName) in the composition of Modules\Subscriber\Entities\Subs
criber. However, the definition differs and is considered incompatible. Class was composed

Oh thanks. I'll check it out now ...

Hey @hmdshariati , what your environment?

  • Laravel version
  • PHP version
  • OS

Hello
I have the same problem.
I m using php slim 3
php 7.3
Centos
image

I'm still working on the fix 😅

A temporary alternative to custom column names...

Create an abstract model, for example:

Migration:

Schema::create('categories', function (Blueprint $table) {
    $table->uuid('identifier');
    $table->string('name');
    $table->timestamps();
});

Abstract model:

<?php

namespace App;

use YourAppRocks\EloquentUuid\Traits\HasUuid;
use Illuminate\Database\Eloquent\Model as EloquentModel;

abstract class BaseModel extends EloquentModel
{
    use HasUuid;
}

Model:

<?php

namespace App;

class Category extends BaseModel
{
    protected $uuidColumnName = 'identifier';
    
    protected $fillable = [
        'name',
    ];
}