namespace BookStack\Http\Controllers;
use Activity;
+use BookStack\Actions\ActivityQueries;
use BookStack\Actions\ActivityType;
use BookStack\Actions\View;
use BookStack\Entities\Models\Bookshelf;
{
$this->checkPermission('book-create-all');
$this->validate($request, [
- 'name' => 'required|string|max:255',
- 'description' => 'string|max:1000',
- 'image' => 'nullable|' . $this->getImageValidationRules(),
+ 'name' => ['required', 'string', 'max:255'],
+ 'description' => ['string', 'max:1000'],
+ 'image' => array_merge(['nullable'], $this->getImageValidationRules()),
]);
$bookshelf = null;
if ($bookshelf) {
$bookshelf->appendBook($book);
- Activity::addForEntity($bookshelf, ActivityType::BOOKSHELF_UPDATE);
+ Activity::add(ActivityType::BOOKSHELF_UPDATE, $bookshelf);
}
return redirect($book->getUrl());
/**
* Display the specified book.
*/
- public function show(Request $request, string $slug)
+ public function show(Request $request, ActivityQueries $activities, string $slug)
{
$book = $this->bookRepo->getBySlug($slug);
$bookChildren = (new BookContents($book))->getTree(true);
- $bookParentShelves = $book->shelves()->visible()->get();
+ $bookParentShelves = $book->shelves()->scopes('visible')->get();
View::incrementFor($book);
if ($request->has('shelf')) {
'current' => $book,
'bookChildren' => $bookChildren,
'bookParentShelves' => $bookParentShelves,
- 'activity' => Activity::entityActivity($book, 20, 1),
+ 'activity' => $activities->entityActivity($book, 20, 1),
]);
}
$book = $this->bookRepo->getBySlug($slug);
$this->checkOwnablePermission('book-update', $book);
$this->validate($request, [
- 'name' => 'required|string|max:255',
- 'description' => 'string|max:1000',
- 'image' => 'nullable|' . $this->getImageValidationRules(),
+ 'name' => ['required', 'string', 'max:255'],
+ 'description' => ['string', 'max:1000'],
+ 'image' => array_merge(['nullable'], $this->getImageValidationRules()),
]);
$book = $this->bookRepo->update($book, $request->all());