repository
repository copied to clipboard
Call to undefined method findWhere
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';
}
}
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
.
You need to install master branch in your project in order to access findWhere method.
I'll tag latest version today ;)
Same here, just cannot find any reference to "findWhere" in the code
in the vendor version obtain by composer not find findWhere and others like findAllBy ...
is not tagged the last version
Tagged, sorry took me too long :)