public function show($categoryName) { $books = Book::whereHas('category', function ($q) use($categoryName) { $q->where('name', 'like', $categoryName); })->orderBy('book_added_at', 'desc')->paginate(config('library.posts_per_page')); $imagePath = \Config::get('library.uploads.webpath'); $imageCoverName = \Config::get('library.uploads.cover_name'); $deffaultImage = \Config::get('library.uploads.deffault_image'); return view('allBook', compact('books', 'imagePath', 'imageCoverName', 'deffaultImage')); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($name) { // $posts = Post::whereHas('comments', function ($query) { // $query->where('content', 'like', 'foo%'); //})->get(); $books = Book::whereHas('authors', function ($q) use($name) { $q->where('name', 'like', $name); })->orderBy('book_added_at', 'desc')->paginate(config('library.posts_per_page')); $imagePath = \Config::get('library.uploads.webpath'); $imageCoverName = \Config::get('library.uploads.cover_name'); $deffaultImage = \Config::get('library.uploads.deffault_image'); return view('allBook', compact('books', 'imagePath', 'imageCoverName', 'deffaultImage')); }
/** * Return all overdue books of this user * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function getOverdue() { return Book::whereHas('transact', function ($query) { $query->where('type', 'loan')->where('expires', '<=', Carbon::now())->where('user_id', $this->attributes['id']); })->get(); }
/** * Get library wide reserved books * @return Book collection */ public static function reserved() { return Book::whereHas('transact', function ($query) { $query->where('type', 'reservation'); })->get(); }