class UserItem extends Pivot { use Uuids; /** * Indicates if the IDs are auto-incrementing. * @var bool */ public $incrementing = false; /** * The "type" of the auto-incrementing ID. * @var string */ public $keyType = 'string'; /** * Create a new pivot model from raw values returned from a query. * @param \Illuminate\Database\Eloquent\Model $parent * @param array $attributes * @param string $table * @param bool $exists * @return static * @throws \Exception */ public static function fromRawAttributes(Model $parent, $attributes, $table, $exists = false) { if (!$exists and !array_key_exists('id', $attributes)) { $attributes['id'] = Uuid::generate()->string; } return parent::fromRawAttributes($parent, $attributes, $table, $exists); } }