为什么在用模型插入数据时出现此错误? [英] Why I get this error while data insert with model?

查看:85
本文介绍了为什么在用模型插入数据时出现此错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是将数据简单地插入表中的模型:

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;

                 }

这是管制员:

 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';
   }
 }

这是路线:

          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.

推荐答案

在包含该模型时,请保留App资本的a.

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

 use App\UserHandle;

这篇关于为什么在用模型插入数据时出现此错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆