Why I get this error while data insert with model?

假装没事ソ 提交于 2019-12-11 14:23:37

问题


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.


回答1:


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

 use App\UserHandle;



回答2:


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

use App\UserHanle;


来源:https://stackoverflow.com/questions/55016312/why-i-get-this-error-while-data-insert-with-model

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!