IsraelOrtuno / Eavquent

EAV modeling package for Laravel and Eloquent – This package is abandoned, please use this fork https://github.com/rinvex/attributes
63 stars 14 forks source link

Interface 'Illuminate\Database\Eloquent\Scope' not found #36

Closed codercms closed 6 years ago

codercms commented 8 years ago

Hey, i'm using the latest Lumen. And created model:

<?php
namespace App\Models;

use Devio\Eavquent\Eavquent;
use Illuminate\Database\Eloquent\Model;

class Books extends Model
{
    use Eavquent;

    // Eager loading all the registered attributes
    protected $with = ['eav'];
}

And added the following route:

$app->get('/books', function() {
    return \App\Models\Books::all();
});

And when i trying to access /books i've got - Whoops, looks like something went wrong. FatalErrorException in EagerLoadScope.php line 10: Interface 'Illuminate\Database\Eloquent\Scope' not found

Is there any way to fix this problem?

IsraelOrtuno commented 8 years ago

Have you bootstrapped Lumen with eloquent?

On Tuesday, 19 April 2016, Dmitry notifications@github.com wrote:

Hey, i'm using latest Lumen. And created model:

<?phpnamespace App\Models;use Devio\Eavquent\Eavquent;use Illuminate\Database\Eloquent\Model;class Books extends Model{ use Eavquent; // Eager loading all the registered attributes protected $with = ['eav'];}

And added the following route:

$app->get('/books', function() { return \App\Models\Books::all();});

And when i trying to access /books i've got - Whoops, looks like something went wrong. FatalErrorException in EagerLoadScope.php line 10: Interface 'Illuminate\Database\Eloquent\Scope' not found

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/IsraelOrtuno/Eavquent/issues/36

Un saludo Israel Ortuño

codercms commented 8 years ago

@IsraelOrtuno yes,the code is below:

require_once __DIR__.'/../vendor/autoload.php';
Dotenv::load(__DIR__.'/../');

$app = new Laravel\Lumen\Application(
    realpath(__DIR__.'/../')
);

$app->withFacades();
$app->withEloquent();
IsraelOrtuno commented 8 years ago

@codercms I have set up it with a fresh lumen app and it works pretty well, just have to focus more on the config stuff but apart of that, model worked perfect. What version of Lumen are you using?

codercms commented 8 years ago

@IsraelOrtuno

php artisan --version
Laravel Framework version Lumen (5.1.6) (Laravel Components 5.1.*)

Maybe i need to execute some additional commands to enable Eloquent's scope interface?

codercms commented 8 years ago

@IsraelOrtuno here is ScopeInterface

image

IsraelOrtuno commented 8 years ago

Yep... I am using Scope which is for 5.2 I think and in Lumen 5.1 you have ScopeInterface, that's the problem...

Will dig into this and get back to you.

rockymontana commented 8 years ago

Why don't you just update to latest lumen? ^o^

codercms commented 8 years ago

@rockymontana I already did it ;)

rockymontana commented 8 years ago

Awesome! Did it help?

codercms commented 8 years ago

@rockymontana sure, that helped :+1:

IsraelOrtuno commented 8 years ago

I think this is will be one of the reasons to stick into 5.1 or 5.2 😓

rockymontana commented 8 years ago

So we should set minimum version to 5.2 and be over with it? :-)

codercms commented 8 years ago

@rockymontana sounds like a good solution

IsraelOrtuno commented 8 years ago

I wanted to use 5.1 because of LTS but looks like 5.2 is going to be easier to maintain.

On Friday, 22 April 2016, Dmitry notifications@github.com wrote:

@rockymontana https://github.com/rockymontana sounds like a good solution

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/IsraelOrtuno/Eavquent/issues/36#issuecomment-213471072

Un saludo Israel Ortuño

rockymontana commented 8 years ago

I would that that the solution here would be to branch out and create a realease / tag for the LTS version.