1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

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

@ -135,9 +135,9 @@ class BookController extends Controller
*/
public function destroy($bookSlug)
{
$bookName = $this->bookRepo->getBySlug($bookSlug)->name;
$book = $this->bookRepo->getBySlug($bookSlug);
Activity::addMessage('book_delete', 0, $book->name);
$this->bookRepo->destroyBySlug($bookSlug);
Activity::addMessage('book_delete', 0, $bookName);
return redirect('/books');
}
}

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());
}
}

View File

@ -4,15 +4,11 @@ namespace Oxbow\Http\Controllers;
use Illuminate\Filesystem\Filesystem as File;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Intervention\Image\Facades\Image as ImageTool;
use Illuminate\Support\Facades\DB;
use Oxbow\Http\Requests;
use Oxbow\Image;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use RegexIterator;
class ImageController extends Controller
{
@ -192,7 +188,7 @@ class ImageController extends Controller
}
}
}
// Delete file and database entry
unlink($folder . '/' . $fileName);
$image->delete();

View File

@ -219,6 +219,7 @@ class PageController extends Controller
$book = $this->bookRepo->getBySlug($bookSlug);
$page = $this->pageRepo->getBySlug($pageSlug, $book->id);
Activity::addMessage('page_delete', $book->id, $page->name);
Activity::removeEntity($page);
$page->delete();
return redirect($book->getUrl());
}