0

Here is the Model which simply inserts data into the table:

namespace App;

use Illuminate\Database\Eloquent\Model;

   class UserHandle extends Model {
            public $timestamps=false;

                 }

Here is the Controller:

 namespace App\Http\Controllers;

 use Illuminate\Http\Request;
 use app\UserHandle;

 class UserHandleCntrl extends Controller {

  public function index(){

         $data = new UserHandle;
         $data->name='Laravel';
         $data->email='dbtcbd@gmail.com';
         $data->username='bdlaravel';
         $data->password='laravel12345';
         $data->save();
         echo 'Data Inserted';
   }
 }

Here is the route :

          Route::get('/user', 'UserHandleCntrl@index');

But when I am trying to insert data into the database I am getting error that model class not found. Why I am getting this and what is the solution. Please help. Bellow is the error screenshot.

enter image description here

Phil
  • 157,677
  • 23
  • 242
  • 245
DEBASHIS BAIDYA
  • 310
  • 1
  • 4
  • 14

2 Answers2

3

Keep the a of App capital while you are including that model.

 use App\UserHandle;
Kamal Paliwal
  • 1,251
  • 8
  • 16
1

including model use App instead of app in your controller file.

use App\UserHanle;
scode2704
  • 108
  • 9