Example #1
0
 /**
  * Restituisce la serie il cui slug è $slug. Se $onlyPublished è true, allora la serie verrà restituita solo se
  * marcata come pubblicata.
  *
  * @param $slug
  * @param bool $onlyPublished
  * @return \Illuminate\Database\Eloquent\Model|null|static
  * @throws NotFoundException
  */
 public function findBySlug($slug, $onlyPublished = false)
 {
     $query = Series::with('articles');
     if ($onlyPublished) {
         $query->published();
     }
     $series = $query->where('slug', '=', $slug)->first();
     if (!$series) {
         throw new NotFoundException();
     }
     return $series;
 }