hootlex / laravel-moderation

A simple Content Moderation System for Laravel 5.* that allows you to Approve or Reject resources like posts, comments, users, etc.
MIT License
526 stars 68 forks source link

Issue with Eloquent\Scope - Laravel 5.1 compatibility issue #19

Open jgardezi opened 7 years ago

jgardezi commented 7 years ago

Hi All,

I am using Laravel 5.1 and getting the following issue with this package.

"Interface 'Illuminate\\Database\\Eloquent\\Scope' not found",

// error details
"file": "/home/vagrant/projects/laravel/MyApp/vendor/hootlex/laravel-moderation/src/ModerationScope.php",
    "class": "Symfony\\Component\\Debug\\Exception\\FatalErrorException",

In my Model I am including it as

use Hootlex\Moderation\Moderatable;

class Collection extends Model
{
    use Moderatable;
}

Please let me know whats wrong with this?

Kind regards, Javed Gardezi

jgardezi commented 7 years ago

Hi,

I have found the problem... its lvl 5.1 compatibility issue.

Laravel 5.1 does not have Illuminate\Database\Eloquent\Scope Interface.

In ModerationScope.php I have changed it to use Illuminate\Database\Eloquent\ScopeInterface and it started working.

Is there a way to add compatibility for Laravel 5.1.* in the offical repository.

stephane-monnot commented 7 years ago

Hi Jgardezi, Maybe you can use a class alias in your application (haven't tested it) :

if (!class_exists('\Illuminate\Database\Eloquent\Scope')) {
    class_alias('\Illuminate\Database\Eloquent\ScopeInterface', '\Illuminate\Database\Eloquent\Scope');
}