src/Repositories/EloquentRepository.php
public function bySlug($slug, $attributes = ['*'])
    {
        if (!request('preview')) {
            $this->published();
        }
        $model = $this->findBy(column('slug'), $slug, $attributes);

        if (is_null($model)) {
            abort(404);
        }

        return $model;
    }
public function bySlug($slug, $attributes = ['*'])
    {
        if (!request('preview')) {
            $this->published();
        }
        $model = $this->findBy(column('slug'), $slug, $attributes);

        if (is_null($model)) {
            abort(404);
        }

        return $model;
    }
public function bySlug ( $ slug , $ attributes = [ '*' ] ) { if ( ! request ( 'preview' ) ) { $ this -> published ( ) ; } $ model = $ this -> findBy ( column ( 'slug' ) , $ slug , $ attributes ) ; if ( is_null ( $ model ) ) { abort ( 404 ) ; } return $ model ; }
Get single model by Slug.

@param string $slug
@param array  $attributes

@return mixed
Get single model by Slug .