public function findBySlug($slug) { $row = $this->database->table('categories')->where('slug', $slug)->first(); if (is_null($row)) { throw new Exception('Category does not exist.'); } return $row; }