Esempio n. 1
0
 public function getAuthors(Request $request)
 {
     $term = $request->input('term');
     $authors = Author::where('name', 'like', '%' . $term . '%')->get();
     foreach ($authors as $author) {
         $aut[] = $author->name;
     }
     return json_encode($aut);
 }
Esempio n. 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $author_id = \App\Author::where('last_name', '=', 'Fitzgerald')->pluck('id');
     DB::table('books')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'title' => 'The Great Gatsby', 'author_id' => $author_id, 'user_id' => 1, 'published' => 1925, 'cover' => 'http://img2.imagesbn.com/p/9780743273565_p0_v4_s114x166.JPG', 'purchase_link' => 'http://www.barnesandnoble.com/w/the-great-gatsby-francis-scott-fitzgerald/1116668135?ean=9780743273565']);
     $author_id = \App\Author::where('last_name', '=', 'Plath')->pluck('id');
     DB::table('books')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'title' => 'The Bell Jar', 'author_id' => $author_id, 'user_id' => 1, 'published' => 1963, 'cover' => 'http://img1.imagesbn.com/p/9780061148514_p0_v2_s114x166.JPG', 'purchase_link' => 'http://www.barnesandnoble.com/w/bell-jar-sylvia-plath/1100550703?ean=9780061148514']);
     $author_id = \App\Author::where('last_name', '=', 'Angelou')->pluck('id');
     DB::table('books')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'title' => 'I Know Why the Caged Bird Sings', 'author_id' => $author_id, 'user_id' => 1, 'published' => 1969, 'cover' => 'http://img1.imagesbn.com/p/9780345514400_p0_v1_s114x166.JPG', 'purchase_link' => 'http://www.barnesandnoble.com/w/i-know-why-the-caged-bird-sings-maya-angelou/1100392955?ean=9780345514400']);
 }
Esempio n. 3
0
 public function getBook()
 {
     $books = 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)->get();
     $genres = Genre::where('deleted', '=', 0)->orderBy('name')->get();
     $authors = Author::where('deleted', '=', 0)->orderBy('name')->get();
     $publishers = Publisher::where('deleted', '=', 0)->orderBy('name')->get();
     $data = array('books' => $books, 'authors' => $authors, 'genres' => $genres, 'publishers' => $publishers);
     return view('admin.pages.book')->with('data', $data);
 }
Esempio n. 4
0
 /**
  * 检查作者是否存在
  *
  **/
 public function isAuthorExist($payload)
 {
     if ($payload['feed']) {
         $author = Author::where('feed', $payload['feed'])->first();
         if ($author) {
             return true;
         } else {
             return false;
         }
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $author_id = \App\Author::where('last_name', '=', 'Fitzgerald')->pluck('id');
     DB::table('books')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'title' => '1.mp4', 'author_id' => $author_id, 'user_id' => 1, 'published' => 100, 'cover' => 'img/thumbnail.png', 'purchase_link' => 'this video gives a overview of the .etc file']);
     $author_id = \App\Author::where('last_name', '=', 'Plath')->pluck('id');
     DB::table('books')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'title' => '2.mp4', 'author_id' => $author_id, 'user_id' => 1, 'published' => 90, 'cover' => 'img/thumbnail.png', 'purchase_link' => 'this is a high level view of the way Laravel is a framework of frameworks']);
     $author_id = \App\Author::where('last_name', '=', 'Angelou')->pluck('id');
     DB::table('books')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'title' => '3.mp4', 'author_id' => $author_id, 'user_id' => 1, 'published' => 90, 'cover' => 'img/thumbnail.png', 'purchase_link' => 'this describes the way Laravel uses the MVC framework']);
     $author_id = \App\Author::where('last_name', '=', 'Angelou')->pluck('id');
     DB::table('books')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'title' => '4.mp4', 'author_id' => $author_id, 'user_id' => 1, 'published' => 90, 'cover' => 'img/thumbnail.png', 'purchase_link' => 'this discusses the routes.php file']);
 }
 /**
  * Display the quotes for given author.
  *
  * @param $slug
  *
  * @return Response
  * @internal param int $slug
  */
 public function quotes($slug)
 {
     try {
         $author = Author::where(['slug' => $slug])->firstOrFail();
         $statusCode = 200;
         $response = ['data' => $author->quotes()->get()];
     } catch (Exception $e) {
         $statusCode = 400;
     } finally {
         return Response::json($response, $statusCode);
     }
 }
Esempio n. 7
0
 public function addbooks()
 {
     header('Content-Type: text/html; charset=utf-8');
     for ($i = 0; $i <= 10; $i++) {
         $user = new User();
         $user->name = $this->generateRandomString(5);
         $user->password = bcrypt($user->name);
         $user->email = $user->name . '@gmail.com';
         $user->save();
     }
     $names = ['%22feliz%20gouveia%22', '%22nuno%20ribeiro%22', '%22jose%20torres%22', '%22borges%20gouveia%22', '%22Sophia%20breyner%22', '%22Fernando%20Pessoa%22', '%22Eça%20De%20Queiros%22'];
     foreach ($names as $name) {
         $content = file_get_contents('https://www.googleapis.com/books/v1/volumes?q=' . $name);
         $content = json_decode($content, true);
         $auts = Author::all('name');
         $authors = array();
         foreach ($auts as $aut) {
             $authors[] = $aut['name'];
         }
         $pubs = Publisher::all('publisher');
         $publishers = array();
         foreach ($pubs as $pub) {
             $publishers[] = $pub['publisher'];
         }
         $cats = Collection::all('collection');
         $categories = array();
         foreach ($cats as $cat) {
             $categories[] = $cat['collection'];
         }
         foreach ($content['items'] as $data) {
             $data = $data['volumeInfo'];
             $book = new Book();
             if (isset($data['title'])) {
                 $book->title = $data['title'];
             }
             if (isset($data['subtitle'])) {
                 $book->subtitle = $data['subtitle'];
             }
             if (isset($data['publishedDate'])) {
                 $book->publishedDate = $data['publishedDate'];
             }
             if (isset($data['description'])) {
                 $book->description = $data['description'];
             }
             if (isset($data['pageCount'])) {
                 $book->pages = $data['pageCount'];
             }
             if (isset($data['language'])) {
                 $book->language = $data['language'];
             }
             if (isset($data['industryIdentifiers'])) {
                 foreach ($data['industryIdentifiers'] as $value) {
                     if ($value['type'] == 'ISBN_13') {
                         $book->isbn13 = $value['identifier'];
                     }
                     if ($value['type'] == 'ISBN_10') {
                         $book->isbn10 = $value['identifier'];
                     }
                 }
             }
             if (isset($data['publisher'])) {
                 if (!in_array($data['publisher'], $publishers)) {
                     $publishers[] = $data['publisher'];
                     $publisher = new Publisher();
                     $publisher->publisher = $data['publisher'];
                     $publisher->save();
                     $publisher_id = $publisher->id;
                 } else {
                     $publisher = Publisher::where('publisher', '=', $data['publisher'])->limit(1)->get();
                     $publisher_id = $publisher[0]->id;
                 }
             }
             if (isset($data['imageLinks']['thumbnail'])) {
                 $book->cover = file_get_contents($data['imageLinks']['thumbnail']);
             }
             $book->price_day = random_int(0, 15);
             $book->price_bail = random_int(10, 50);
             $book->price_sale = random_int(10, 79);
             $books[] = $book;
             $book->id_publisher = $publisher_id;
             $book->id_user = rand(1, 10);
             $book->save();
             $book_id = $book->id;
             if (isset($data['categories'])) {
                 foreach ($data['categories'] as $value) {
                     if (!in_array($value, $categories)) {
                         $categories[] = $value;
                         $category = new Collection();
                         $category->collection = $value;
                         $category->save();
                         $category_id = $category->id;
                         $collections = new Book_Collection();
                         $collections->book_id = $book_id;
                         $collections->collection_id = $category_id;
                         $collections->save();
                     } else {
                         $category = Collection::where('collection', '=', $value)->limit(1)->get();
                         $collections = new Book_Collection();
                         $collections->book_id = $book_id;
                         $collections->collection_id = $category[0]->id;
                         $collections->save();
                     }
                 }
             }
             if (isset($data['authors'])) {
                 foreach ($data['authors'] as $value) {
                     if (!in_array($value, $authors)) {
                         $authors[] = $value;
                         $author = new Author();
                         $author->name = $value;
                         $author->save();
                         $author_id = $author->id;
                         $author_book = new Author_Book();
                         $author_book->book_id = $book_id;
                         $author_book->author_id = $author_id;
                         $author_book->save();
                     } else {
                         $author = Author::where('name', 'like', $value)->limit(1)->get();
                         $author_book = new Author_Book();
                         $author_book->book_id = $book_id;
                         $author_book->author_id = $author[0]->id;
                         $author_book->save();
                     }
                 }
             }
             # code...
         }
     }
 }
Esempio n. 8
0
 public function getAuthor()
 {
     $authors = Author::where('deleted', '=', 0)->orderBy('name')->get();
     return view('admin.pages.author')->with('authors', $authors);
 }
Esempio n. 9
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function edit()
 {
     $user_id = Auth::user()->id;
     $data = INPUT::all();
     $rules = $this->rules();
     $messages = $this->messages();
     $validator = Validator::make($data, $rules, $messages);
     if (!$validator->fails()) {
         $book = Book::find($data['id']);
         $book->title = $data['title'];
         $book->subtitle = $data['subtitle'];
         $book->publishedDate = $data['publishedDate'];
         $book->description = $data['description'];
         $book->pages = $data['pages'];
         $book->isbn10 = $data['isbn10'];
         $book->isbn13 = $data['isbn13'];
         $book->price_day = $data['price_day'];
         $book->price_bail = $data['price_bail'];
         $book->price_sale = $data['price_sale'];
         $book->language = $data['language'];
         if ($data['publisher'] != $book->id_publisher) {
             if ($data['publisher'] != '0') {
                 $book->id_publisher = $data['publisher'];
             } else {
                 $publisher = new Publisher();
                 $publisher->publisher = $data['newpublisher'];
                 $publisher->save();
                 $book->id_publisher = $publisher->id;
             }
         }
         if (isset($data['cover'])) {
             $book->cover = file_get_contents($data['cover']);
         }
         $book_id = $book->id;
         Book_Collection::where('book_id', $book_id)->delete();
         Author_Book::where('book_id', $book_id)->delete();
         $book_collection = new Book_Collection();
         $book_collection->book_id = $book_id;
         $book_collection->collection_id = $data['collection'];
         $authors = explode(',', $data['authors']);
         foreach ($authors as $author) {
             $tmp = Author::where('name', 'like', $author)->limit(1)->get();
             if (count($tmp) > 0) {
                 $author_book = new Author_Book();
                 $author_book->book_id = $book_id;
                 $author_book->author_id = $tmp[0]->id;
                 $author_book->save();
             } else {
                 $newAuthor = new Author();
                 $newAuthor->name = $author;
                 $newAuthor->save();
                 $author_id = $newAuthor->id;
                 $author_book = new Author_Book();
                 $author_book->book_id = $book_id;
                 $author_book->author_id = $author_id;
                 $author_book->save();
             }
         }
         $book->save();
         return redirect('book/edit/' . $book_id . '');
     }
     return back()->withInput($data)->withErrors($validator);
 }
Esempio n. 10
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $application = Application::find($id);
     $author = Author::where('id', '=', $application->author_id);
     return view('application.edit', compact('application', 'author'));
 }
Esempio n. 11
0
 public function author()
 {
     if (Request::ajax()) {
         $data = Request::get('data');
         $sort = Request::get('sort');
         $list = Request::get('list');
         switch ($data) {
             case 'pp':
                 $author = Author::find($list);
                 $author_book = Book::where('author_id', $list)->get();
                 return view('front.partials.list_item_pp_author', ['data' => $author, 'author_book' => $author_book]);
             case 'word':
                 $author = Author::where('name', 'LIKE', $list . '%');
                 return view('front.partials.list_item_word', ['data' => $author->paginate(9), 'word' => $list]);
             default:
                 $authors = DB::table('Authors');
                 $author = HomeController::sort($authors, $sort);
                 return view('front.partials.list_item_all', ['data' => $author->paginate(9)]);
         }
     }
     $author_list = Author::orderBy('name', 'ASC')->paginate(9);
     $author_word = Author::select(DB::raw('substr(name,1,1) as alpha'))->groupBy(DB::raw('substr(name,1,1)'))->get();
     return view('front.tacgia', ['author_word' => $author_word, 'data' => $author_list, 'name_page' => 'Tác giả', 'table_name' => 'Authors']);
 }
Esempio n. 12
0
 /**
  * Show all send messages in a list 
  *
  * @param  int  $id
  * @return Response
  */
 public function mailSendAll()
 {
     $members = Member::all();
     //all data of member collection
     $id = Auth::id();
     $author = User::find($id);
     //$author = User::find($id);
     $sends = Author::where('mail_send', '=', '1')->where('mail_author', '=', $id)->get();
     //retrieve data of unread message
     $unread = Inbox::where('mail_read', '=', '0')->where('member_id', '=', $id)->get()->count();
     return view('vendor/flatAdmin/mailSendAll', compact(array('members', 'author', 'unread', 'id', 'sends')));
 }