*/
public function getAllPaginated(int $count = 20, string $sort = 'name', string $order = 'asc'): LengthAwarePaginator
{
- return Bookshelf::visible()->with('visibleBooks')
- ->orderBy($sort, $order)->paginate($count);
+ return Bookshelf::visible()
+ ->with('visibleBooks')
+ ->orderBy($sort, $order)
+ ->paginate($count);
}
/**
/**
* Create a new shelf in the system.
*/
- public function update(Bookshelf $shelf, array $input, array $bookIds): Bookshelf
+ public function update(Bookshelf $shelf, array $input, ?array $bookIds): Bookshelf
{
$this->baseRepo->update($shelf, $input);
- $this->updateBooks($shelf, $bookIds);
+
+ if (!is_null($bookIds)) {
+ $this->updateBooks($shelf, $bookIds);
+ }
+
return $shelf;
}
* @throws ImageUploadException
* @throws Exception
*/
- public function updateCoverImage(Bookshelf $shelf, UploadedFile $coverImage = null, bool $removeImage = false)
+ public function updateCoverImage(Bookshelf $shelf, ?UploadedFile $coverImage, bool $removeImage = false)
{
$this->baseRepo->updateCoverImage($shelf, $coverImage, $removeImage);
}
public function destroy(Bookshelf $shelf)
{
$trashCan = new TrashCan();
- $trashCan->destroyShelf($shelf);
+ $trashCan->softDestroyShelf($shelf);
+ $trashCan->autoClearOld();
}
}