Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uuid for user creation in tenant #18

Open
xx1196 opened this issue Nov 7, 2024 · 1 comment
Open

uuid for user creation in tenant #18

xx1196 opened this issue Nov 7, 2024 · 1 comment

Comments

@xx1196
Copy link
Contributor

xx1196 commented Nov 7, 2024

Hello, i have an issue, in my user model i use UUID and i generate this with a eloquent event, but the package use db insert in users tabla and the problem is that my event is not fire and get this error

SQLSTATE[23502]: Not null violation: 7 ERROR: el valor nulo en la columna «id» de la relación «users» viola la restricción de no nulo DETAIL: La fila que falla contiene (null, test, null, null, null, null, [email protected], null, $2y$12$vW/VaLA7uSMSB3Elh6o.0uWq4JW30pn34XqqceLhcUzRTJbSR.Fka, null, null, null, null, null, null, null, null, null, null, null, null). (Connection: dynamic, SQL: insert into "users" ("name", "email", "password") values (Bellas artes, [email protected], $2y$12$vW/VaLA7uSMSB3Elh6o.0uWq4JW30pn34XqqceLhcUzRTJbSR.Fka))

this is the trait for users

`

namespace App\Traits;

use Illuminate\Database\Eloquent\Model;
use Ramsey\Uuid\Uuid;

trait HasUuid
{
/**
* Boot function to auto-assign a UUID when creating a model.
*/
protected static function bootHasUuid(): void
{
static::creating(function (Model $model) {
if (!$model->getKey()) {
$model->{$model->getKeyName()} = generateUuid();
}
});
}

/**
 * Override getIncrementing to false for UUIDs.
 */
public function getIncrementing(): bool
{
    return false;
}

/**
 * Override getKeyType to string for UUIDs.
 */
public function getKeyType(): string
{
    return 'string';
}

}
`

Copy link

linear bot commented Nov 7, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant