skip to Main Content

I have a some problem… ORM
When I use
php artisan tinker,


use App\Models\User

    $u = new User();

 $u->title = 'sale';

    $u->content = 'auto ...';

    $u->price = 2500;

HERE ARE GOOD EVERYTHING, BUT…

when I type command

$u->save();

I see

IlluminateDatabaseQueryException SQLSTATE[HY000]: General error: 1 no such table: users (SQL: insert into "users" ("title", "content", "price", "updated_at", "created_at") values (sale, auto …, 2500, 2024-10-30 14:31:15, 2024-10-30 14:31:15)).

What can it be? All migrations is good, I have a table sqlite.
I have done everything from book, just change names of models etc

Laraver 9, PHP 8.3, Ubuntu, local

I wanna create my own project for pet project… I check it app DB Browser for SQLite.

2

Answers


  1. The error suggest that the users table doesn’t exist in your database

    Login or Signup to reply.
  2. here are some reasons

    1. make sure the table is in the db, browse the tables in your DB
    2. the table name might not meet the Laravel approach (name not users)
    3. set the table name inside the model
    protected $table = 'users'; // or whatever the table name
    

    so check your DB tale and provide a screen and more details if not a case

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search