/** * Display the specified resource. * * @param int $id * @return Response */ public function show($string) { $book_list = Books::select('book_id', 'title', 'author', 'description', 'category_id')->where('title', 'like', '%' . $string . '%')->orWhere('author', 'like', '%' . $string . '%')->orderBy('book_id'); $book_list = $book_list->get(); foreach ($book_list as $book) { $conditions = array('book_id' => $book->book_id, 'available_status' => 1); $count = Issue::where($conditions)->count(); $book->avaliability = $count > 0 ? true : false; } return $book_list; }