Skip to content

New model instances don’t return their incrementing id with Lada-Cache v6.0.1 #139

@MGApcDev

Description

@MGApcDev

Just trying to upgrade from v5.4 to v6.0.1

After upgrading to Lada-Cache v6, newly created Eloquent models no longer return their auto-incrementing id when using Model::create() (seems to also. affect ->save() on new records).

Example:

Model:

<?php

namespace App\Http\Models;

use App\Http\Enums\FolderTreeElementType;
use App\Http\Models\FolderTreeElement\FolderTreeElementQueryBuilder;
use Illuminate\Database\Eloquent\Model;
use Spiritix\LadaCache\Database\LadaCacheTrait;

class FolderTreeElement extends Model
{
    use LadaCacheTrait;

    protected $table = 'folder_tree_elements';
    protected $guarded = ['id', 'created_at'];
    protected $casts = [
        'properties' => 'json',
        'type' => FolderTreeElementType::class,
    ];
}

Code executed in Tinker:

$f = FolderTreeElement::create([
    'client_id' => 4,
    'type' => FolderTreeElementType::SPACER,
    'folder_id' => 86415,
    'properties' => [],
]);

Result with Lada-Cache enabled:

array:7 [
  "client_id" => 4
  "type" => "SPACER"
  "folder_id" => 86415
  "properties" => []
  "updated_at" => "2025-10-29T08:44:56.000000Z"
  "created_at" => "2025-10-29T08:44:56.000000Z"
  "id" => null
]

Result after disabling Lada-Cache (php artisan lada-cache:disable):

array:7 [
  "client_id" => 4
  "type" => "SPACER"
  "folder_id" => 86415
  "properties" => []
  "updated_at" => "2025-10-29T08:47:11.000000Z"
  "created_at" => "2025-10-29T08:47:11.000000Z"
  "id" => 20
]

My Database schema:

Image

Expected Behavior
The id field should be populated automatically, just like when Lada-Cache is disabled.

Actual Behavior
When Lada-Cache v6 is enabled, the new model instance has id => null, even though the record is correctly inserted in the database.

Environment

  • Laravel version: 12.x
  • PHP version: 8.3.20
  • Lada-Cache version: 6.0.1
  • Database: MySQL
  • Lada-Cache: Running on Redis connection

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions