Fixed entity messages on delete. Fixes #21.

This commit is contained in:
Dan Brown
2015-08-23 14:20:34 +01:00
parent 40b629d35d
commit 0b222c7734
6 changed files with 27 additions and 11 deletions

View File

@ -137,15 +137,15 @@ class ChapterController extends Controller
{
$book = $this->bookRepo->getBySlug($bookSlug);
$chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
$chapterName = $chapter->name;
if(count($chapter->pages) > 0) {
foreach($chapter->pages as $page) {
$page->chapter_id = 0;
$page->save();
}
}
Activity::removeEntity($chapter);
Activity::addMessage('chapter_delete', $book->id, $chapter->name);
$chapter->delete();
Activity::addMessage('chapter_delete', $book->id, $chapterName);
return redirect($book->getUrl());
}
}