skip to Main Content

SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘app.infos’ doesn’t exist.

home controller

<?php

namespace AppHttpControllers;

// use IlluminateHttpRequest;
use AppHttpControllersController;
use AppModelsinfo;

class homeController extends Controller
{
    public function index(){
        $data=info::all();
        return view('home',['data'=>$data]);
    }
}

web php

Route::get('home', [homeController::class ,'index']);

2

Answers


  1. Make sure table name is "infos" not info

    After that run following command

    php artisan migrate
    
    Login or Signup to reply.
  2. change your table ‘info’ to ‘infos’ or just add (protected $table = ‘info’) to your model

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