- /**
- * 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();
- }
-