-1

I have a database name lrvesikhon and there is a table named 'person'. I created a model named 'Person' and also create a controller named 'PersonsController'. I also config the .env file. But some error occurs. The error:

enter image description here

My code -

PersonController -

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;

class PersonsCotroller extends Controller
{
    public function index(){

        $person_list = Person::all();
        dd($person_list);
        
    }
}

Web -

<?php

Route::get('/', 'PersonsCotroller@index');

Person Model -

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Person extends Model
{
    protected $table = "person";
}
halfer
  • 19,824
  • 17
  • 99
  • 186
  • Try using some web IDE optimised for PHP. Its minor syntax miss to add "use" statement for the specified Model. Almost all regular IDE's will hint you for that miss. – Svetoslav Nov 17 '21 at 19:25
  • Does this answer your question? [Laravel - Model class not found](https://stackoverflow.com/questions/28350232/laravel-model-class-not-found) – miken32 Nov 17 '21 at 21:42
  • If you're using a Laravel version lower than 8, include `use App\Person;` right after the `use Illuminate\Http\Request;` line. – fufubrocat Nov 18 '21 at 02:34

2 Answers2

0

Your haven't hooked up the model class.

Add in your controller after namespace App\Http\Controllers

use App\Models\Person;
Andrey
  • 712
  • 6
  • 16
Web Desg
  • 101
  • 1
0

Write bellow code after use App\Http\Request;

use App\Models\Person;

If your model Person is not in Models directory change to use App\your-directory\Person;