Kevin.a
Kevin.a

Reputation: 4296

Model not functioning FatalErrorException

I created a model called category.php as you can see in the code provided below:

<?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 = [];
}

Now whenever i try to run my site i get this error:

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

I dont know what i did wrong here all help would be appreciated.

Thanks in advance,

-Kevin

Upvotes: 0

Views: 52

Answers (1)

Rafael Berro
Rafael Berro

Reputation: 2601

You should have a class called "Models" inside your models folder, or, extend the eloquent model the right way.

<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Category extends Model
{
}

Upvotes: 1

Related Questions