1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-31 15:24:31 +03:00

Added better entity deletion and commented up repos

This commit is contained in:
Dan Brown
2015-11-21 18:05:03 +00:00
parent ea55b7f141
commit 61ae96c5f8
10 changed files with 155 additions and 34 deletions

View File

@ -42,7 +42,7 @@ class BookController extends Controller
public function index()
{
$books = $this->bookRepo->getAllPaginated(10);
$recents = $this->bookRepo->getRecentlyViewed(10, 0);
$recents = $this->signedIn ? $this->bookRepo->getRecentlyViewed(10, 0) : false;
return view('books/index', ['books' => $books, 'recents' => $recents]);
}

View File

@ -146,15 +146,8 @@ class ChapterController extends Controller
$this->checkPermission('chapter-delete');
$book = $this->bookRepo->getBySlug($bookSlug);
$chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
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();
$this->chapterRepo->destroy($chapter);
return redirect($book->getUrl());
}
}

View File

@ -34,8 +34,8 @@ class HomeController extends Controller
public function index()
{
$activity = Activity::latest();
$recentlyViewed = Views::getUserRecentlyViewed(10, 0);
return view('home', ['activity' => $activity, 'recents' => $recentlyViewed]);
$recents = $this->signedIn ? Views::getUserRecentlyViewed(10, 0) : $this->bookRepo->getLatest(10);
return view('home', ['activity' => $activity, 'recents' => $recents]);
}
}

View File

@ -164,8 +164,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();
$this->pageRepo->destroy($page);
return redirect($book->getUrl());
}