예제 #1
0
 public function updateNewBook()
 {
     $book = Book::where('ID', '=', Input::get("id"))->get();
     $book->Inhalt = Input::get("inhalt");
     $book->save();
     return View::make('updateNew');
 }
예제 #2
0
 function update()
 {
     $params = $this->input->post();
     $obj = new Book();
     $obj->where('id', $params['id'])->update($params);
     echo $obj->check_last_query();
 }
예제 #3
0
 /**
  * Searches and returns any books added in the last 24 hours
  *
  * @return Collection
  */
 public static function getBooksAddedInTheLast24Hours()
 {
     # Timestamp of 24 hours ago
     $past_24_hours = strtotime('-1 day');
     # Convert to MySQL timestamp
     $past_24_hours = date('Y-m-d H:i:s', $past_24_hours);
     $books = Book::where('created_at', '>', $past_24_hours)->get();
     return $books;
 }
예제 #4
0
 public function delete($id)
 {
     $exist = Book::where('id', $id)->count();
     if ($exist == 0) {
         Session::put('msgfail', 'Failed to delete book.');
         return Redirect::back()->withInput();
     }
     $book = Book::find($id);
     unlink(public_path() . "/uploads/book/" . $book->file);
     Book::where('id', $id)->delete();
     Session::put('msgsuccess', 'Successfully deleted book.');
     return Redirect::back();
 }
예제 #5
0
 public function getSearchBooks($key)
 {
     if (isset($key)) {
         $books = Book::where('name', 'like', '%' . $key . '%')->get();
         if (isset($books)) {
             return json_encode(array('message' => 'found', 'books' => $books->toArray()));
         } else {
             return json_encode(array('message' => 'empty'));
         }
     } else {
         return json_encode(array('message' => 'invalid'));
     }
 }
예제 #6
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $product = Product::find($id)->toArray();
     $additional = null;
     if ($product['category'] == 'laptop') {
         $additional = Laptop::where('id_product', $id)->first()->toArray();
     } elseif ($product['category'] == 'book') {
         $additional = Book::where('id_product', $id)->first()->toArray();
     }
     $product = array_merge($product, $additional);
     $head = array('title' => $product['name']);
     $data = array('head' => $head, 'product' => $product);
     return view('product.show', $data);
 }
예제 #7
0
 public function postAdd()
 {
     $rules = array('isbn' => 'required|size:13', 'title' => 'required|min:3', 'author' => 'required|alpha', 'category' => 'required', 'publishing_house' => 'required', 'page_no' => 'required|numeric', 'publishing_year' => 'required|max:4');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         //all fields are set
         $isbn = Input::get('isbn');
         //check if isbn exists in the books table
         $_test = Book::where('isbn', '=', $isbn)->first();
         if ($_test != null) {
             //the book is in the books table, just add him for this user
             $mybook = new LibraryBooks();
             $mybook->user_id = Auth::user()->id;
             $mybook->book_isbn = $isbn;
             $mybook->copies_no = 1;
             //TODO: change this
             $mybook->save();
             return "This book was saved on library_books";
         } else {
             //the book doesn't exist in the books table
             //add it there then add it to the user
             $mybook = new Book();
             $mybook->author = Input::get('author');
             $mybook->category = Input::get('category');
             $mybook->isbn = $isbn;
             $mybook->page_no = Input::get('page_no');
             $mybook->publishing_house = Input::get('publishing_house');
             $mybook->publishing_year = Input::get('publishing_year');
             $mybook->title = Input::get('title');
             $mybook->save();
             //now that the book was added to books
             //add him to the user
             $new_book = new LibraryBooks();
             $new_book->user_id = Auth::user()->id;
             $new_book->book_isbn = $isbn;
             $new_book->copies_no = 1;
             //TODO: change this
             $new_book->save();
             return "This was stored to books with id " . $mybook->id;
         }
     } else {
         return Redirect::to('/api/v1/add')->withErrors($validator);
     }
 }
 public function testDoubleSaveOneToMany()
 {
     $author = User::create(array('name' => 'George R. R. Martin'));
     $book = Book::create(array('title' => 'A Game of Thrones'));
     $author->books()->save($book);
     $author->books()->save($book);
     $author->save();
     $this->assertEquals(1, $author->books()->count());
     $this->assertEquals($author->_id, $book->author_id);
     $author = User::where('name', 'George R. R. Martin')->first();
     $book = Book::where('title', 'A Game of Thrones')->first();
     $this->assertEquals(1, $author->books()->count());
     $this->assertEquals($author->_id, $book->author_id);
     $author->books()->save($book);
     $author->books()->save($book);
     $author->save();
     $this->assertEquals(1, $author->books()->count());
     $this->assertEquals($author->_id, $book->author_id);
 }
예제 #9
0
 public function showPrivate($sl)
 {
     $chapter = Chapter::where('secret_link', '=', $sl)->first();
     if ($chapter->public_state == true && Book::where('id', '=', $chapter->book_id)->first()->public_state == true) {
         return Redirect::to('/chapter/' . $chapter->slug);
     }
     $markdownParser = new MarkdownParser();
     $markdownText = $markdownParser->transformMarkdown($chapter->text);
     return View::make('chapter.single', array('chapter' => $chapter, 'chapter_text' => $markdownText, 'pageTitle' => 'Chapter: ' . $chapter->title));
 }
 public function myprofile()
 {
     $_action = 'myprofile';
     $_viewtype = 'traveler/self';
     $_viewdata = array('env' => $this->_env, 'action' => $_action);
     if (!Auth::check()) {
         return Redirect::to('home/');
     } else {
         $_viewdata['books'] = Book::where('traveler_id', '=', Auth::user()->id)->get();
     }
     return View::make($_viewtype, $_viewdata);
 }
예제 #11
0
 public function getDeleteBook($id)
 {
     $book = Book::where('id', '=', $id)->first();
     if ($book) {
         $book->delete();
         return Redirect::to('/browse-books')->with('flash_message', 'Delete successfuly!');
     } else {
         return Redirect::to('/browse-books')->with('flash_message', 'Delete failed! Try again...!');
     }
 }
 public function queryWithOrder()
 {
     $books = Book::where('published', '>', 1950)->orderBy('title', 'desc')->get();
     Book::pretty_debug($books);
 }
예제 #13
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $book = Book::where('id', '=', $id)->orWhere('slug', '=', $id)->first();
     $chapters = Chapter::where('book_id', '=', $book->id)->where('public_state', '=', true)->paginate(15);
     if ($book) {
         if ($book->public_state == true) {
             return View::make('book.single', array('book' => $book, 'chapters' => $chapters, 'pageTitle' => 'Book: ' . $book->title));
         } elseif (Sentry::Check() && $book->author_id == Sentry::getUser()->id) {
             return View::make('book.single', array('book' => $book, 'chapters' => $chapters, 'pageTitle' => 'Book: ' . $book->title));
         } else {
             return Redirect::to('/')->with('global_error', 'You can\'t access private resources without a secret link, which can be received from creation\'s author.');
         }
     }
     return Redirect::to('/')->with('global_error', 'Sorry, book you are trying to reach doesn\'t exist.');
 }
예제 #14
0
<?php

Route::get('/books', function () {
    $books = DB::table('books')->paginate(10);
    return View::make('management')->with('books', $books);
});
Route::get('/books/edit/{id}', function ($id) {
    $exist = Book::where('id', $id)->count();
    if ($exist == 0) {
        Session::put('msgfail', 'Failed to edit book.');
        return Redirect::back()->withInput();
    }
    $book = Book::find($id);
    return View::make('edit_books')->with('book', $book);
});
Route::post('/books/edit/{id}', array('uses' => 'BookController@edit'));
Route::post('/books', array('uses' => 'BookController@add', 'as' => 'books'));
Route::get('/books/delete/{id}', array('uses' => 'BookController@delete'));
예제 #15
0
 public function getBooks($id)
 {
     if (isset($id)) {
         $books = Book::where('course_id', $id)->get();
         if (isset($books)) {
             return json_encode(array('message' => 'found', 'books' => $books->toArray()));
         } else {
             return json_encode(array('message' => 'empty'));
         }
     } else {
         return json_encode(array('message' => 'invalid'));
     }
 }
 function runJoinSearch($i)
 {
     $books = Book::where('title', 'Hello' . $i)->with('author')->first();
 }