模型无法运行FatalErrorException

时间:2016-10-04 20:46:01

标签: php laravel model

我创建了一个名为category.php的模型,如下面的代码所示:

<?php

namespace App\Models;
use Illuminate\Database\Eloquent\Model;

class Category extends Models
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $table = 'categories';

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $fillable = ['name',];

    protected $hidden = [];
}

现在每当我尝试运行我的网站时,我都会收到此错误:

FatalErrorException in category.php line 7:
Class 'App\Models\Models' not found

我不知道我在这里做错了所有的帮助将不胜感激。

提前致谢,

-Kevin

1 个答案:

答案 0 :(得分:1)

你应该在你的模型文件夹中有一个名为“Models”的类,或者以正确的方式扩展这个雄辩的模型。

<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Category extends Model
{
}