/** * Display a listing of the resource. * * @return Response */ public function index() { $user = Auth::user(); $books = Book::all(); $transactions = User::order()->get(); return view('operator.order.index', ['user' => $user, 'books' => $books, 'transactions' => $transactions]); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $user = Auth::user(); $books = Book::all(); $transactions = User::join('book_users', 'users.id', '=', 'book_users.user_id')->join('books', 'books.id', '=', 'book_users.book_id')->select('books.title', 'users.name', 'book_users.created_at', 'book_users.updated_at', 'book_users.status')->whereNotIn('status', ['pesan'])->get(); return view('operator.borrow.index', ['user' => $user, 'books' => $books, 'transactions' => $transactions]); }
/** * Display a listing of the resource. * * @return Response */ public function index() { // $books = Book::all(); return view('books.index', compact('books')); //return view('welcome'); }
public function index() { //$book = new \App\Book(); //$books = $book->all(); $books = \App\Book::all(); return view('books', ['books' => $books]); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $user = Auth::user(); $books = Book::all(); $transactions = User::transactionBorrow()->orderBy('created_at', 'desc')->get(); return view('operator.transactions.index', ['user' => $user, 'books' => $books, 'transactions' => $transactions]); }
function getBookWithEloquent() { $books = new Book(); foreach ($books->all() as $book) { echo $book->title . '<br/>'; } return 'getBookWithEloquent'; }
function getExample9() { #eager load the authors with the books $books = \App\Book::all(); foreach ($books as $book) { echo $book->author->first_name . ' ' . $book->author->last_name . ' wrote '; } dump($books->toArray()); }
/** * Run the database seeds. * * @return void */ public function run() { // Add to 10 random user 5 random books $users = User::all('id')->random(5); foreach ($users as $user) { $books = Book::all('id')->random(3); foreach ($books as $book) { DB::table('users_books')->insert(['user_id' => $user->id, 'book_id' => $book->id]); } } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $books = Book::all(); foreach ($books as $book) { //TODO: make a method in model for retreiving authors and genres $authors = Book::find($book->book_id)->authors()->get(); $genres = Book::find($book->book_id)->genres()->get(); $book->authors = $authors; $book->genres = $genres; } return view('books/books', ['books' => $books]); }
public function index() { $books = \App\Book::all(); $category = \App\Category::all(); // return \App\Book::with(["Author"])->get(); // dd($books->toArray()); // if (!\Auth::user()->admin == '1') // { // return \Redirect::to('index')->with('error', 'You are not Admin'); // } return view('admin.bookslist', compact('books', 'category')); }
/** * Displays a listing of all the books available and allows their sorting as well. * * @return \Illuminate\Http\Response */ public function index() { $sortBy = Input::get('sortBy'); $order = Input::get('order'); if ($sortBy and $order == 'asc') { $books = Book::orderBy($sortBy, 'ASC')->get(); } elseif ($sortBy and $order == "desc") { $books = Book::orderBy($sortBy, 'DESC')->get(); } else { $books = Book::all(); } return view('home')->with('books', $books); }
public function showBooks() { $books = Book::all(); function getExcerpt($str, $startPos = 0, $maxLength = 100) { if (strlen($str) > $maxLength) { $excerpt = substr($str, $startPos, $maxLength - 3); $lastSpace = strrpos($excerpt, ' '); $excerpt = substr($excerpt, 0, $lastSpace); $excerpt .= ' ...'; } else { $excerpt = $str; } return $excerpt; } foreach ($books as $book) { $book->description = getExcerpt($book->description, 0, 1000); } return View('books', compact('books')); }
public function importBooks() { $rules = array('csvfile' => 'required|mimes:csv,txt'); try { $file = Input::file('csvfile'); if (is_null($file)) { throw new Exception("File upload required"); } Excel::load($file, function ($reader) { $results = $reader->all(); foreach ($results as $row) { $book = new Book(); # First row should be like "Title, Author" $data = array('title' => $row->title, 'author' => $row->author); $book->fill($data); $book->save(); } }); } catch (Exception $e) { return Redirect::to('/')->with(['books' => Book::all(), 'errors' => $e->getMessage()]); } return Redirect::to('/')->with(['books' => Book::all()]); //return Redirect::to('/')->with('csvdata', $results); }
public function getNearestUser(Request $request, $book_id) { session_start(); if (session_id() == "" || !isset($_SESSION['latitude'])) { return redirect()->route('home'); } else { if (isset($_SESSION['latitude'])) { // get all the books from the book database. $books = Book::where("book_id", $book_id)->get(); $valid_users = []; foreach ($books as $book) { $matches = []; $found_user = $book->user; $theta = doubleval($found_user['longitude']) - doubleval($_SESSION['longitude']); $dist = sin(deg2rad(doubleval($found_user['latitude']))) * sin(deg2rad(doubleval($_SESSION['latitude']))) + cos(deg2rad(doubleval($found_user['latitude']))) * cos(deg2rad(doubleval($_SESSION['latitude']))) * cos(deg2rad($theta)); $dist = acos($dist); $dist = rad2deg($dist); $miles = round($dist * 60 * 1.1515 * 1.609344, 1); $matches['location_name'] = $found_user['location_name']; $matches['firstname'] = $found_user['name']; $matches['distance'] = $miles; $valid_users[] = $matches; } // more suggestions based on your location $suggestions = []; $more_books = Book::all()->take(100); foreach ($more_books as $more) { $matches = []; $found_user = $more->user; $theta = doubleval($found_user['longitude']) - doubleval($_SESSION['longitude']); $dist = sin(deg2rad(doubleval($found_user['latitude']))) * sin(deg2rad(doubleval($_SESSION['latitude']))) + cos(deg2rad(doubleval($found_user['latitude']))) * cos(deg2rad(doubleval($_SESSION['latitude']))) * cos(deg2rad($theta)); $dist = acos($dist); $dist = rad2deg($dist); $miles = round($dist * 60 * 1.1515 * 1.609344, 1); $matches['location_name'] = $found_user['location_name']; $matches['firstname'] = $found_user['name']; $matches['distance'] = $miles; $matches['title'] = $more->title; $matches['image'] = $more->image; $matches['rating'] = $more->rating; $matches['publisher'] = $more->publisher; $matches['isbn'] = $more->isbn; $suggestions[] = $matches; } // sort the array based on distance uasort($valid_users, function ($a) { return $a['distance']; }); $valid_users = array_slice($valid_users, 0, 3); // sort the array based on distance // uasort($suggestions, function ($b) { // return $b['distance']; // }); $suggestions = $this->sort_by_key($suggestions, 'distance'); $suggestions = array_slice($suggestions, 0, 18); $book = $books[0]; // return $suggestions; return view("static.foundBooks", compact("valid_users", "book", "suggestions")); } } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $books = Book::all(); return view('index')->withBooks($books); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $books = Book::all(); return view('books.index', compact('books')); }
public function index() { $Books = Book::all(); return response()->json($Books); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $Book = \App\Book::all(); return response()->json(['msg' => 'success', 'Book' => $Book->toArray()], 200); }
public function bookList() { $books = Book::all(); return view('books.index', ['books' => $books]); }
/** * Display a listing of the resource. * * @return Response */ public function index() { // return view('admin')->withBooks(Book::all()); }
/** * Display a listing of the Books. * * @return Response */ public function index() { $books = Book::all(); return Response::json($books); }
public function getIndex() { $books = \App\Book::all(); return view('video.index')->with('books', $books); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { return new JsonResponse(Book::all(), 200); }
/** * Display a list of all of the user's orders. * * @param Request $request * @return Response */ public function index(Request $request) { $books = Book::all(); return view('books.index', ['books' => $books]); }
function json() { $data = Book::all(); return $data->toJson(); }
/** * Display an api of the books. * * @return json */ public function api() { return Response::json(Book::all()); }
public function searchBooks() { $books = \App\Book::all(); //->lists('title','id'); return $books; }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $books = Book::all(); echo $books; }
public function getShowbooks() { $books = Book::all(); return view('work.books.showbooks')->withBooks($books); }
public function showIndex() { $books = Book::all(); $data = array('books' => Book::all()); return View::make('books', $data); }