コード例 #1
0
 /**
  * Responds to requests to GET /books
  */
 public function getIndex(Request $request)
 {
     // Get all the books "owned" by the current logged in users
     // Sort in descending order by id
     $books = \App\Book::where('user_id', '=', \Auth::id())->orderBy('id', 'DESC')->get();
     return view('books.index')->with('books', $books);
 }
コード例 #2
0
ファイル: HomeController.php プロジェクト: klokand/Nintex
 public function borrow2()
 {
     //$user = user::where('email', '=', Input::get('bemail'))->firstOrFail();
     $returnData = "";
     $name = Input::get("name");
     $email = Input::get("email");
     if (Request::ajax()) {
         $userCount = User::where('email', '=', Input::get('email'))->count();
         $bookCount = Book::where('barcode', '=', Input::get('barcode'))->count();
         if ($userCount == 1) {
             $returnData = $returnData . " user existed ";
             $user = User::where('email', '=', Input::get('email'))->find(1);
         }
         if ($userCount == 0) {
             $name = Input::get("name");
             $email = Input::get("email");
             $user = user::create(array('email' => $email, 'name' => $name));
             $returnData = $returnData . " user is created ";
         }
         if ($bookCount == 1) {
             $returnData = $returnData . " book existed ";
             $book = Book::where('barcode', '=', Input::get('barcode'))->find(1);
         }
         if ($bookCount == 0) {
             $title = Input::get('title');
             $author = Input::get('author');
             $barcode = Input::get('barcode');
             $book = book::create(array('title' => $title, 'author' => $author, 'barcode' => $barcode));
             $returnData = $returnData . " book is created ";
         }
         $borrow = Borrow::create(array('user_id' => $user->id, 'book_id' => $book->id));
         $returnData = $returnData . " borrowing is successful user id =" . $user->id . " book id =" . $book->id;
     }
     return $returnData;
 }
コード例 #3
0
 public function schoolClicked($id)
 {
     $schools = School::all();
     $programs = Program::where('school_id', '=', $id)->get();
     $books = Book::where('school_id', '=', $id)->get();
     return view('home')->with('programs', $programs)->with('schools', $schools);
 }
コード例 #4
0
 public function book($id)
 {
     $settings = Setting::first();
     $books = Book::get();
     $currentbook = Book::where('id', $id)->firstOrFail();
     return view('front.book', ['books' => $books, 'settings' => $settings, 'currentbook' => $currentbook]);
 }
コード例 #5
0
ファイル: BookService.php プロジェクト: owemus/personal_be
 public function deleteAllWithBookType($book_type_id)
 {
     // Get All Books
     $books = Book::where('book_type_id', $book_type_id)->delete();
     // Passing data to response service
     return $this->responseService->returnMessage($books, 'No Books were Found.');
 }
コード例 #6
0
 /**
  * @Given 書籍 :bookName 已被 :username 借出
  */
 public function bookCheckedOutByUser($bookName, $username)
 {
     $book = Book::where('name', $bookName)->first();
     $user = User::where('username', $username)->first();
     $book->available = false;
     $book->save();
     factory(CheckoutHistory::class)->create(['book_id' => $book->id, 'user_id' => $user->id]);
 }
コード例 #7
0
 function getExample10()
 {
     $book = \App\Book::where('title', '=', 'The Great Gatsby')->first();
     echo $book->title . ' is tagged with : ';
     foreach ($book->tags as $tag) {
         echo $tag->name . ' ';
     }
 }
コード例 #8
0
 function getExample7()
 {
     $book = \App\Book::where('author', 'LIKE', '%Scott%')->first();
     if ($book) {
         return $book->title;
     } else {
         return 'Book not found.';
     }
 }
コード例 #9
0
 /**
  * Treat this method as a controller action.
  * Return view() or other content to display.
  */
 public function run()
 {
     //
     $listItem = Book::where('cate_id', '=', $this->config['id'])->orderBy(DB::raw('RAND()'))->take($this->config['count'])->get();
     // return view("widgets.featured_books", [
     //     'config' => $this->config,
     //     'featuredItem' => $featuredItem
     // ]);
     return view("widgets.samecategory_books", compact('listItem'));
 }
コード例 #10
0
 public function create()
 {
     if (Auth::check()) {
         $user = Auth::user();
         $count = Book::where('user_id', '=', $user->id)->count();
         $mybooks = Book::where('user_id', '=', $user->id)->orderBy('updated_at', 'desc')->take(10)->get();
         return view('sell')->with('mybooks', $mybooks)->with('count', $count);
     } else {
         return redirect()->route('getLogin');
     }
 }
コード例 #11
0
 function getExample5()
 {
     //DELETE
     $book = new Book();
     $harry_potter = Book::where('author', '=', 'J.K.Rowling')->first();
     if ($harry_potter != null) {
         $harry_potter->delete();
         echo 'deleted Harry Potter';
     }
     return 'example5';
 }
コード例 #12
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $books = ['The Great Gatsby' => ['1'], 'A Fire in the Deep' => ['5'], 'Deepness in the Sky' => ['10']];
     foreach ($books as $title => $rating) {
         $book = \App\Book::where('title', 'like', $title)->first();
         foreach ($rating as $ratingName) {
             $rating = \App\Rating::where('rating', 'LIKE', $ratingName)->first();
             $book->ratings()->save($rating);
         }
     }
 }
コード例 #13
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $books = ['The Great Gatsby' => ['novel', 'fiction', 'classic', 'wealth'], 'The Bell Jar' => ['novel', 'fiction', 'classic', 'women'], 'I Know Why the Caged Bird Sings' => ['autobiography', 'nonfiction', 'classic', 'women']];
     foreach ($books as $title => $tags) {
         $book = \App\Book::where('title', 'like', $title)->first();
         foreach ($tags as $tagName) {
             $tag = \App\Tag::where('name', 'LIKE', $tagName)->first();
             $book->tags()->save($tag);
         }
     }
 }
コード例 #14
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $books = ['screen cast' => ['php', 'html', 'css', 'mysql'], 'pdf cast' => ['php', 'html', 'css', 'js'], 'flash cast' => ['forms', 'front-end', 'css', 'js']];
     foreach ($books as $title => $tags) {
         $book = \App\Book::where('title', 'like', $title)->first();
         foreach ($tags as $tagName) {
             $tag = \App\Tag::where('name', 'LIKE', $tagName)->first();
             $book->tags()->save($tag);
         }
     }
 }
コード例 #15
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $books = ['1.mp4' => ['mysql', 'security', 'php', 'model'], '2.mp4' => ['mysql', 'security', 'php', 'controller'], '3.mp4' => ['ui', 'nonfiction', 'js', 'view'], '4.mp4' => ['mysql', 'ui', 'html', 'css']];
     foreach ($books as $title => $tags) {
         $book = \App\Book::where('title', 'like', $title)->first();
         foreach ($tags as $tagName) {
             $tag = \App\Tag::where('name', 'LIKE', $tagName)->first();
             $book->tags()->save($tag);
         }
     }
 }
 public function search(Request $request)
 {
     if (strlen($request->search) >= 1) {
         $books = Book::where('book_title', 'like', "%{$request->search}%")->paginate(3);
         if ($books->total() > 1) {
             Flash::success('Result');
         } else {
             Flash::success('Not Found');
         }
     } else {
         $books = Book::where('book_title', 'like', "%aaaaaaaaaaaaaaaaaaaa%")->paginate(3);
     }
     return view('home', compact('books'));
 }
コード例 #17
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $books = ["The Great Gatsby" => ['Jill', 'Jamal'], "A Fire in the Deep" => ['jon macleod', 'Jill'], "Deepness in the Sky" => ['Jamal', 'Jill', 'jon macleod']];
     foreach ($books as $title => $user) {
         # First get the book
         $book = \App\Book::where('title', 'like', $title)->first();
         # Now loop through each comment for this user, adding the pivot
         foreach ($user as $userName) {
             $user = \App\User::where('name', 'LIKE', $userName)->first();
             # Connect this comment to this book
             $book->users()->save($user);
         }
     }
 }
コード例 #18
0
 public function advancedSearchAction(Request $request)
 {
     $num = 10;
     $username = $request->session()->get("username");
     $name = $request->input("name");
     $author = $request->input("author");
     $publishing = $request->input("publishing");
     $category = $request->input("category");
     $isbn = $request->input("isbn");
     $books = Book::where("book-name", "like", '%' . $name . '%')->where("author", "like", '%' . $author . '%')->where('publishing', 'like', '%' . $publishing . '%')->where('category-id', '=', $category)->where('isbn', 'like', '%' . $isbn . '%')->paginate($num);
     $books->appends(["name" => $name, "author" => $author, "publishing" => $publishing, "category" => $category, "isbn" => $isbn]);
     $categories = $this->getCategoryArray(Category::all());
     return view('/reader/BookList', ['username' => $username, 'books' => $books, 'categories' => $categories]);
 }
コード例 #19
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     # First, create an array of all the books we want to associate comments with
     # The *key* will be the book title, and the *value* will be an array of comments.
     $books = ['The Great Gatsby' => ['good', 'great'], 'A Fire in the Deep' => ['great', 'bad'], 'Deepness in the Sky' => ['good', 'great', 'bad']];
     # Now loop through the above array, creating a new pivot for each book to comment
     foreach ($books as $title => $comment) {
         # First get the book
         $book = \App\Book::where('title', 'like', $title)->first();
         # Now loop through each comment for this book, adding the pivot
         foreach ($comment as $commentName) {
             $comment = \App\Comment::where('comment', 'LIKE', $commentName)->first();
             # Connect this comment to this book
             $book->comments()->save($comment);
         }
     }
 }
コード例 #20
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     # First, create an array of all the books we want to associate tags with
     # The *key* will be the book title, and the *value* will be an array of tags.
     $books = ['The Great Gatsby' => ['novel', 'fiction', 'classic', 'wealth'], 'The Bell Jar' => ['novel', 'fiction', 'classic', 'women'], 'I Know Why the Caged Bird Sings' => ['autobiography', 'nonfiction', 'classic', 'women']];
     # Now loop through the above array, creating a new pivot for each book to tag
     foreach ($books as $title => $tags) {
         # First get the book
         $book = \App\Book::where('title', 'like', $title)->first();
         # Now loop through each tag for this book, adding the pivot
         foreach ($tags as $tagName) {
             $tag = \App\Tag::where('name', 'LIKE', $tagName)->first();
             # Connect this tag to this book
             $book->tags()->save($tag);
         }
     }
 }
コード例 #21
0
 public function sortBook(Request $request)
 {
     if ($request->sort_type == 'name') {
         $books = Book::where('genre_id', '=', $request->id)->orderBy('title');
     } else {
         if ($request->sort_type == 'price_up') {
             $books = Book::where('genre_id', '=', $request->id)->orderBy('price');
         } else {
             $books = Book::where('genre_id', '=', $request->id)->orderBy('price', 'desc');
         }
     }
     if ($books->count() > 0) {
         $data = array('books' => $books->get());
         return $data;
     } else {
         return 'false';
     }
 }
コード例 #22
0
ファイル: BookController.php プロジェクト: Amina24/Boot-Camp
 public function buy_books()
 {
     // session_start();
     if (!isset($_SESSION['user_id'])) {
         $msg = "You are not Login , Please Login First...";
         return view('login')->with('message', $msg);
     }
     $price = 0;
     $cid = cart::max('c_id') + 1;
     foreach ($_SESSION['cart'] as $item) {
         cart::create(['b_id' => $item["id"], 'c_id' => $cid]);
         $b = Book::where('b_id', $item["id"])->first();
         $price = $price + $b->price;
     }
     trans::create(['u_id' => $_SESSION['user_id'], 'c_id' => $cid, 'amount' => $price]);
     $_SESSION['cart'] = array();
     $msg = "Thank you for buying, Book are added to your transaction...";
     return redirect()->action('UserController@show_trans');
 }
コード例 #23
0
    public function adminIndex()
    {
        if (Auth::check()) {
            if (Auth::user()->userable_type == 'customer') {
                return view('errors.404');
            } else {
                $countNewOrder = Order::where('shipped', '=', 0)->where('seen', '=', 0)->where('deleted', '=', 0)->count();
                $countNewCustomer = Customer::where('created_at', '>', date('Y-m-d'))->where('created_at', '<', date('Y-m-d H:i:s'))->count();
                $countSale = Book::where('sale', '>', 0)->count();
                $books_sale = Book::join('genre', 'genre.id', '=', 'book.genre_id')->join('author', 'author.id', '=', 'book.author_id')->join('publisher', 'publisher.id', '=', 'book.publisher_id')->select('book.id', 'title', 'genre_id', 'genre.name as genre_name', 'author_id', 'author.name as author_name', 'publisher_id', 'publisher.name as publisher_name', 'image', 'isbn', 'description_short', 'price', 'sale', 'quantity')->where('book.deleted', '=', 0)->where('book.sale', '>', 0)->get();
                $books_selling = Book::join('genre', 'genre.id', '=', 'book.genre_id')->join('author', 'author.id', '=', 'book.author_id')->join('publisher', 'publisher.id', '=', 'book.publisher_id')->join('order_detail', 'order_detail.book_id', '=', 'book.id')->selectRaw('book.id, title, genre_id, genre.name as genre_name,
					author_id, author.name as author_name, publisher_id, publisher.name as publisher_name,
					image, isbn, description_short, price, sale, book.quantity, SUM(order_detail.quantity) as sum_quantity')->where('book.deleted', '=', 0)->groupBy('book_id')->orderBy('sum_quantity', 'desc')->take(10)->get();
                $data = array('books_sale' => $books_sale, 'books_selling' => $books_selling);
                return view('admin.pages.index', compact('countNewOrder', 'countNewCustomer', 'countSale'))->with('data', $data);
            }
        } else {
            return view('errors.404');
        }
    }
コード例 #24
0
 public function deleteFromBooks()
 {
     $errors = array();
     $data = array();
     // Getting posted data and decodeing json ANGULAR POST
     $_POST = json_decode(file_get_contents('php://input'), true);
     // checking for blank values.
     if (empty($_POST['id'])) {
         $errors['id'] = 'ID is required.';
     }
     if (!empty($errors)) {
         $data['errors'] = $errors;
     } else {
         $data['message'] = $_POST['id'];
         $book_id = $_POST['id'];
         \App\Book::where('id', '=', $book_id)->delete();
     }
     // response back.
     echo json_encode($data);
 }
コード例 #25
0
ファイル: SearchController.php プロジェクト: r8filipe/LAPR
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function getBooks(Request $request)
 {
     try {
         $term = $request->input();
         $url = '';
         if (count($term) > 1) {
             $books = Book::where('books.active', 1);
             if ($term['title'] != '') {
                 $books = $books->where('title', 'like', '%' . $request->input('title') . '%');
             }
             $url['title'] = $term['title'];
             if ($term['author'] != '') {
                 $books = $books->join('author_book', 'books.id', '=', 'author_book.book_id');
                 $books = $books->join('authors', 'author_book.author_id', '=', 'authors.id');
                 $books = $books->where('authors.name', 'like', '%' . $request->input('author') . '%');
             }
             $url['author'] = $term['author'];
             if ($term['collection'] != '') {
                 $books = $books->join('books_collections', 'books_collections.book_id', '=', 'books.id');
                 $books = $books->where('books_collections.collection_id', '=', $request->input('collection'));
             }
             $url['collection'] = $term['collection'];
             if ($term['sort'] != '') {
                 $books = $books->orderBy('price_day', $term['sort']);
             }
             $url['sort'] = $term['sort'];
             $books = $books->select('books.*');
             $books = $books->paginate(6);
         } else {
             $books = \App\Book::where('active', '1')->paginate(6);
         }
     } catch (\Exception $e) {
         return back();
     } finally {
         $collections = ['' => ''] + \App\Collection::lists('collection', 'id')->all();
         return view('home', ['books' => $books, 'collections' => $collections, 'url' => $url]);
     }
 }
コード例 #26
0
 public function generate($vendor_slug, $tour_slug, $schedule_id)
 {
     // -------------------------------------------------
     // check vendor
     // -------------------------------------------------
     $vendor = Vendor::SlugIs($vendor_slug)->first();
     if (!$vendor) {
         App::abort(404);
     }
     // -------------------------------------------------
     // check tour
     // -------------------------------------------------
     $tour = $vendor->tours()->slugIs($tour_slug)->first();
     if (!$tour) {
         App::abort(404);
     }
     // -------------------------------------------------
     // schedule
     // -------------------------------------------------
     $schedule = $tour->schedules()->find($schedule_id);
     if (!$schedule) {
         App::abort(404);
     }
     // -------------------------------------------------
     // generate voucher
     // -------------------------------------------------
     $book = Book::where('user_id', '=', Auth::id())->ofSchedule($schedule->id)->first();
     if (!$book) {
         $book = new Book();
         $book->fill(['discount_currency' => $schedule->currency, 'discount' => $schedule->discount, 'discount_code' => str_random(6), 'user_id' => Auth::id(), 'schedule_id' => $schedule->id]);
         if (!$book->save()) {
             return redirect()->back()->withErrors($book->getErrors);
         }
     }
     return redirect()->route('web.me.index');
 }
コード例 #27
0
 public function destroy($id)
 {
     Book::where('id', $id)->delete();
     return redirect('books');
 }
コード例 #28
0
 /**
  * Handle search
  * @param Request $request
  * @return Response
  */
 public function search(Request $request)
 {
     if ($request->input('form') == 'basic_search') {
         $this->validate($request, ['key_words' => 'required']);
         $queryString = str_replace(' ', '+', $request->input('key_words'));
         return redirect()->route('studentResults', [$queryString]);
     }
     if ($request->input('form') == 'refined_search') {
         $isbn = $request->input('isbn', null);
         $pub = $request->input('publisher', null);
         $title = $request->input('title', null);
         $author = $request->input('author', null);
         if (!is_null($isbn)) {
             $book = Book::where('isbn', $isbn)->first();
             if (is_null($book)) {
                 $keywords = trim($pub . ' ' . $title . ' ' . $author);
                 $queryString = str_replace(' ', '+', $keywords);
                 return redirect()->route('studentResults', [$queryString]);
             } else {
                 return redirect()->route('studentResults', ['found', $book->id]);
             }
         }
     }
 }
コード例 #29
0
 /**
  *
  * Searches books based on either title or author name
  *
  * @return $this|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function search()
 {
     $criteria = Input::get('criteria');
     $needle = Input::get('searchQuery');
     if ($criteria) {
         $books = Book::where($criteria, 'LIKE', "%{$needle}%")->get();
         return view('search')->with('books', $books);
     } else {
         return view('search');
     }
 }
コード例 #30
0
ファイル: BookController.php プロジェクト: rhsu0268/foobooks
 /**
  * Responds to requests to GET /books
  */
 public function getIndex()
 {
     $books = \App\Book::where('user_id', '=', \Auth::id())->orderBy('id', 'DESC')->get();
     //dump($books->toArray());
     return view('books.index')->with('books', $books);
 }