Tuesday 30 September 2014

Class 'app\models\Eloquent' not found in Laravel

If you are creating Model Class on custom folder and if you are using Eloquent, please don't forgot to use the namespace as well as use Eloquent as below;

In fact not calling use Eloquent can cause the following error;
Class 'app\models\Eloquent' not found in Laravel

The sample class can be written as below;
namespace backend;

use Eloquent;

class Page extends Eloquent {

    protected $fillable = array('id', 'alias', 'title', 'content', 'last_updated', 'status', 'views');

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'pages';

    /*
     * Function action
     * 
     * @return return type
     */
    public function youFunctionName()
    {
     // code here   
    }
}// End of class

No comments:

Post a Comment

Please post any queries and comments here.