本文介绍了在routes.php第22行中出现FatalErrorException:找不到类“绘画"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试从视频教程中学习Laravel迁移时遇到了此错误.导师在 app/models 文件夹中创建了一个名为 Painting.php 的文件. Painting.php 的内容是:
I got this error when I was trying to learn Laravel migrations from a video tutorial. The tutor created a file named Painting.php in the app/models folder. The content of Painting.php is:
<?php
class Painting extends Eloquent{
}
?>
,然后在 routes.php 中:
Route::get('/', function () {
$painting = new Painting; //**this thing generates error**
$painting->title='Do no wrong';
$painting->save();
return view('welcome');
});
现在,问题是我应该在哪里放置 Painting.php 文件,因为Laravel 5.1中没有 models 文件夹?
Now , question is where I am supposed to place Painting.php file since there is no models folder in Laravel 5.1?
推荐答案
您需要Painting
类的名称空间:
<?php
namespace App;
class Painting extends Eloquent {}
以及 routes.php 中的use语句:
<?php
use App\Painting;
此方案假定 Painting.php 位于 app 文件夹中.
This scenario assumes Painting.php resides in the app folder.
这篇关于在routes.php第22行中出现FatalErrorException:找不到类“绘画"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!