在web.php Laravel 5中找不到类'绘画'

时间:2017-08-22 05:30:33

标签: php laravel-5

大家好,当我尝试将数据插入到工作表画面时,我是Laravel的新手,现在浏览器投掷(1/1)FatalErrorException Class 'Painting' not found in web.php(第15行) 希望得到你的帮助。谢谢!

这是web.php

Route::get('/', function () {
    $painting = new Painting; //line 15
    $painting->title = 'Do No Wronge';
    $painting->artist = 'D. DoRight';
    $painting->year = 2017;
    $painting->save();
    return view('welcome');
});

以下是app文件夹中的Painting.php

<?php

namespace App;

class Painting extends Eloquent
{

}
?>

即使FatalErrorException in routes.php line 22: Class 'Painting' not found没有为我正在使用的版本

提供正确的答案

1 个答案:

答案 0 :(得分:0)

已修改的文件[工作解决方案]

这是 web.php

<?php
use App\Painting;

Route::get('/', function () {
  $painting = new Painting; //line 15
  $painting->title = 'Do No Wronge';
  $painting->artist = 'D. DoRight';
  $painting->year = 2017;
  $painting->save();
  return view('welcome');
});

以下是app文件夹中的 Painting.php

<?php 
namespace App;

use Illuminate\Database\Eloquent\Model;

class Painting extends Model
{

}