Search code examples
laravel-4revisionable

Laravel 4 Versionable Package error: Class 'MyApp\Models\Eloquent' not found


I'm trying to use the Versionable Package in my Laravel 4 app based on the new, trait based implementation like this

<?php


use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

namespace MyApp\Models;

class User extends Eloquent implements UserInterface, RemindableInterface {

    use Venturecraft\Revisionable\Revisionable;
    ...

When i use this code above, I get this error

Class 'MyApp\Models\Eloquent' not found

I have also tried changing the namespace to app\models but it still shows the not found error.

Please could someone help me out here? I followed all the instructions on the Github page but as I'm new to Laravel, I may be missing something.


Solution

  • You could use either of the following solutions:

    Change your class declaration to:

    class User extends \Eloquent implements \UserInterface, \RemindableInterface
    

    Or, simply remove the line:

    namespace MyApp\Models;
    

    I would recommend taking the second solution (removing the namespace) for now, until you are comfortable with namespaces in PHP.

    Additionally, you should be using RevisionableTrait, not Revisionable, e.g.,

    <?php
    
    use Illuminate\Auth\UserInterface;
    use Illuminate\Auth\Reminders\RemindableInterface;
    
    class User extends Eloquent implements UserInterface, RemindableInterface {
    
        use Venturecraft\Revisionable\RevisionableTrait;