Search code examples
phpmysqllaravel-10laravel-novasoft-delete

Laravel Nova. Column not found: 1054 Unknown column '*.deleted_at'


I'm using Laravel Nova 4 (Laravel 10.43.0, PHP 8.2.8). When using soft deletion, I get the error Column not found: 1054 Unknown column '*.deleted_at', where * is the table of the entity for which I use it. Full SQL request in the exception:

select * from `users` where `id` = 1 and `users`.`deleted_at` is null limit 1

If I execute this query in the SQL console in PhpStorm, it will say that there is no such column, but the query itself will execute and do it correctly. An example of an implementation with a user. enter image description here enter image description here

Migration:

// ...
Schema::create('users', function (Blueprint $table) {
    // ...
    $table->softDeletes();
    // ...
});

Model:

// ...
class User extends Authenticatable
{
    // ...
    use SoftDeletes;
    // ...
}

Solution

  • The source of the problem has been found. There were three files in the root of my project: .env, .env.local, .env.prod, the last two were used by the console command to quickly change the environment. After I put the .env.* files in a separate folder, the application began to work like clockwork.