public function renderDestroy() { $categoryId = $this->getInt('id'); $articlesInCategory = Article::collection(['category_id' => $categoryId]); $videosInCategory = Video::collection(['category_id' => $categoryId]); if ($articlesInCategory->hasMappers() || $videosInCategory->hasMappers()) { Redirect::to('/' . $this->baseUri())->with('msg', new TransportMessage('error', 'Category cannot be deleted. Some Articles/Videos belong to it'))->now(); } else { $category = new Category($categoryId); $category->delete(); Redirect::to('/' . $this->baseUri())->with('msg', new TransportMessage('success', 'Category was successfully deleted'))->now(); } }
public function renderIndex() { $Videos = Video::collection()->loadAll(); return new Index($Videos); }