websemantics / builder-extension

Scaffold your PyroCMS apps in style for a more pleasurable and productive coding experience.
https://github.com/pyrocms-templates
MIT License
12 stars 4 forks source link

[Feature]: Add findBySlug function into repositories #20

Closed edster closed 7 years ago

edster commented 7 years ago

If you can add a findBySlug to the respoiroty that would be great, use it alot and would be nice to not always having to add it in.

/**
     * Find a stream by it's slug.
     *
     * @param $slug
     * @return null|StreamRepositoryInterface
     */
    public function findBySlug($slug)
    {
        return $this->model->where('slug', $slug)->first();
    }
websemantics commented 7 years ago

Looking at the code, there's something more generic but quite similar

$repo->findBy('slug', $slug);

To use with id, etc

$repo->findBy('id', $id);

Not too far from suggested code. Will close but feel free to re-open if you still need findBySlug method specifically.

Ps. apologies for such a poor response time! I've been taken away from Pyro world over the last while for work related projects,