2

I am trying to use this package:

https://github.com/VentureCraft/revisionable

But I get:

Fatal error: Class 'Auth' not found in /var/www/html/selection/vendor/venturecraft/revisionable/src/Venturecraft/Revisionable/RevisionableTrait.php

and the same for DB.

In the code he uses \

\DB::table($revision->getTable())->insert($revisions);

If I add a use to the Facade and ditch the \ it works.

Why is this happening and is there a way to fix it, without modifying the package?

Further Information.

The problem is happening in this trait:

Source

I am trying to use in my model , as described in the instructions:

class Record extends Model

{
    use \Venturecraft\Revisionable\RevisionableTrait;

I guess the problem is that \DB isn't working. Should it work without a use?

Here is my Model:

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

use Illuminate\Database\Eloquent\SoftDeletes;
use Venturecraft\Revisionable\RevisionableTrait;

//use Venturecraft\Revisionable\RevisionableTrait;


class Record extends Model

{
use RevisionableTrait;

    use SoftDeletes;

    //make these instances of Carbon
    protected $dates = [
        'created_at',
        'updated_at',
        'deleted_at',
        'date_selected'
    ];

    /**
     * Fillable fields
     *
     * @var array
     */
    protected $fillable = array('product_id', 'best', 'seconds', 'pitched', 'area_id', 'user_id', 'date_selected','selector_id');


    public static function boot()
    {
        parent::boot();
    }

}

Just as a test, I tried to use \DB in my controller and I get: Class 'DB' not found in 255 Should this work?

Working now, my app.php was corrupt. :-(

Mick
  • 1,401
  • 4
  • 23
  • 40
  • Can you post the file that the trait is being used in? – Chris Mar 28 '16 at 11:19
  • Are you using an older version? It looks like last version includes https://github.com/VentureCraft/revisionable/blob/1.27.0/src/Venturecraft/Revisionable/RevisionableTrait.php#L274 – Israel Ortuño Mar 28 '16 at 11:25
  • I installed using the instructions: "venturecraft/revisionable": "1.*", – Mick Mar 28 '16 at 11:30
  • Why are you using the first slash on your use statement in the trait? You don't need it. Maybe that is causing the problem (\Venturecraft\Revisionable\RevisionableTrait; => Venturecraft\Revisionable\RevisionableTrait;). Vendor files are PSR, they already have a scope. Can you try removing it? – subzeta Mar 28 '16 at 11:36
  • Because it says so in the instructions and without it I get: 'App\Venturecraft\Revisionable\RevisionableTrait' not found in /var/www/html/selection/app/Record.php on line 17 – Mick Mar 28 '16 at 11:53
  • @Mick Is it possible for you to post the complete Record model class ? – terry low Mar 28 '16 at 12:46

0 Answers0