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:
@ -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]);
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user