repository icon indicating copy to clipboard operation
repository copied to clipboard

Call to undefined method findWhere

Open maxi032 opened this issue 9 years ago • 6 comments

I am getting the above message and I don't know what I am doing wrong. I am calling the findWhere method from a view composer. Here is my code

use Eventsapp\Repositories\SectionRepository; use Eventsapp\Repositories\PageRepository; use Eventsapp\Repositories\PostRepository;

class OnePageComposer{

protected $postsRepo, $pagesRepo, $sectionsRepo;

public function __construct(
    PageRepository $pagesRepo,
    SectionRepository $sectionsRepo,
    PostRepository $postsRepo,
    )
{
    $this->sectionsRepo = $sectionsRepo;
    $this->pagesRepo    = $pagesRepo;
    $this->postsRepo    = $postsRepo;
}

public function compose($view){
    $view->with([
        'sections' => $this->sectionsRepo->findWhere(['status'=>1]),
        'homepage' => $this->pagesRepo->getHomepage()
    ]);
}

}

My SectionRepository looks like this: use Bosnadev\Repositories\Contracts\RepositoryInterface; use Bosnadev\Repositories\Eloquent\Repository;

class SectionRepository extends Repository{

public function model() {
    return 'App\Models\Section';
}

}

maxi032 avatar Jun 09 '15 18:06 maxi032

Correct me if I'm wrong!

@maxi032 Hey! Now I'm studying this package. I have the same problem, so I looked into the code. Somehow findWhere method is no more available. Seems that you can achieve this by doing like this:

// If you only have a single query condition
$sections = $this->sectionRepo->findBy('status', '1');

// If you have more than two conditions
$this->sectionRepo->pushCriteria(new YourCriteria1);
$this->sectionRepo->pushCriteria(new YourCriteria2);
$sections = $this->sectionRepo->all();

UPDATE. Oh! I found findWhere() method at Eloquent/Repository.php.

appkr avatar Jun 15 '15 06:06 appkr

You need to install master branch in your project in order to access findWhere method.

jdsingh avatar Jun 29 '15 11:06 jdsingh

I'll tag latest version today ;)

mirzap avatar Jun 29 '15 12:06 mirzap

Same here, just cannot find any reference to "findWhere" in the code

OxMarco avatar Jul 09 '15 08:07 OxMarco

in the vendor version obtain by composer not find findWhere and others like findAllBy ...

is not tagged the last version

carlituxman avatar Aug 19 '15 07:08 carlituxman

Tagged, sorry took me too long :)

mirzap avatar Aug 19 '15 08:08 mirzap