コード例 #1
0
 /**
  * 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]);
 }
コード例 #2
0
 /**
  * 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]);
 }
コード例 #3
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     $books = Book::all();
     return view('books.index', compact('books'));
     //return view('welcome');
 }
コード例 #4
0
 public function index()
 {
     //$book = new \App\Book();
     //$books = $book->all();
     $books = \App\Book::all();
     return view('books', ['books' => $books]);
 }
コード例 #5
0
 /**
  * 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]);
 }
コード例 #6
0
 function getBookWithEloquent()
 {
     $books = new Book();
     foreach ($books->all() as $book) {
         echo $book->title . '<br/>';
     }
     return 'getBookWithEloquent';
 }
コード例 #7
0
 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());
 }
コード例 #8
0
 /**
  * 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]);
         }
     }
 }
コード例 #9
0
 /**
  * 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]);
 }
コード例 #10
0
 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'));
 }
コード例 #11
0
 /**
  * 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);
 }
コード例 #12
0
 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'));
 }
コード例 #13
0
 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);
 }
コード例 #14
0
 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"));
         }
     }
 }
コード例 #15
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $books = Book::all();
     return view('index')->withBooks($books);
 }
コード例 #16
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $books = Book::all();
     return view('books.index', compact('books'));
 }
コード例 #17
0
 public function index()
 {
     $Books = Book::all();
     return response()->json($Books);
 }
コード例 #18
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $Book = \App\Book::all();
     return response()->json(['msg' => 'success', 'Book' => $Book->toArray()], 200);
 }
コード例 #19
0
 public function bookList()
 {
     $books = Book::all();
     return view('books.index', ['books' => $books]);
 }
コード例 #20
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     return view('admin')->withBooks(Book::all());
 }
コード例 #21
0
ファイル: BookController.php プロジェクト: a1ex7/front-end
 /**
  * Display a listing of the Books.
  *
  * @return Response
  */
 public function index()
 {
     $books = Book::all();
     return Response::json($books);
 }
コード例 #22
0
 public function getIndex()
 {
     $books = \App\Book::all();
     return view('video.index')->with('books', $books);
 }
コード例 #23
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return new JsonResponse(Book::all(), 200);
 }
コード例 #24
0
ファイル: BookController.php プロジェクト: anhtt93/BookStore
 /**
  * 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]);
 }
コード例 #25
0
 function json()
 {
     $data = Book::all();
     return $data->toJson();
 }
コード例 #26
0
ファイル: BooksController.php プロジェクト: pr-dev/macopedia
 /**
  * Display an api of the books.
  *
  * @return json
  */
 public function api()
 {
     return Response::json(Book::all());
 }
コード例 #27
0
 public function searchBooks()
 {
     $books = \App\Book::all();
     //->lists('title','id');
     return $books;
 }
コード例 #28
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $books = Book::all();
     echo $books;
 }
コード例 #29
0
ファイル: BooksController.php プロジェクト: swordyt/work
 public function getShowbooks()
 {
     $books = Book::all();
     return view('work.books.showbooks')->withBooks($books);
 }
コード例 #30
0
ファイル: BooksController.php プロジェクト: Zuviaganys/lesson
 public function showIndex()
 {
     $books = Book::all();
     $data = array('books' => Book::all());
     return View::make('books', $data);
 }