laravel-moderation icon indicating copy to clipboard operation
laravel-moderation copied to clipboard

Issue with Eloquent\Scope - Laravel 5.1 compatibility issue

Open jgardezi opened this issue 7 years ago • 2 comments

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 avatar Mar 02 '17 01:03 jgardezi

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.

jgardezi avatar Mar 02 '17 03:03 jgardezi

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');
}

stephane-monnot avatar Mar 28 '17 19:03 stephane-monnot