-<?php namespace BookStack\Entities\Models;
+<?php
+
+namespace BookStack\Entities\Models;
use BookStack\Uploads\Image;
-use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
/**
* Get the books in this shelf.
* Should not be used directly since does not take into account permissions.
+ *
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function books()
return $this->books()->visible();
}
- /**
- * Get the books in this shelf that are visible to the current user with sorted by custom parameter
- * @param string $sort - Chosen Column to be sorted
- * @param string $order - Order of the sort
- * @return Collection
- */
- public function visibleBooksByCustomSorting(string $sort = 'name', string $order = 'asc'): Collection
- {
- return $this->belongsToMany(Book::class, 'bookshelves_books', 'bookshelf_id', 'book_id')
- ->orderBy($sort, $order)
- ->visible()
- ->get();
- }
-
/**
* Get the url for this bookshelf.
*/
/**
* Returns BookShelf cover image, if cover does not exists return default cover image.
- * @param int $width - Width of the image
+ *
+ * @param int $width - Width of the image
* @param int $height - Height of the image
+ *
* @return string
*/
public function getBookCover($width = 440, $height = 250)
} catch (\Exception $err) {
$cover = $default;
}
+
return $cover;
}
/**
- * Get the cover image of the shelf
+ * Get the cover image of the shelf.
*/
public function cover(): BelongsTo
{
/**
* Check if this shelf contains the given book.
+ *
* @param Book $book
+ *
* @return bool
*/
public function contains(Book $book): bool
/**
* Add a book to the end of this shelf.
+ *
* @param Book $book
*/
public function appendBook(Book $book)