public function store(Request $request)
 {
     $input = $request->all();
     $input['user_id'] = auth()->user()->id;
     Book::create($input);
     return redirect()->route('admin.books.index');
 }
Ejemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('books')->truncate();
     $faker = \Faker\Factory::create();
     for ($count = 0; $count < 500; $count++) {
         Book::create(['title' => $faker->sentence(), 'desc' => $faker->text(), 'cover' => $faker->imageUrl()]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     Book::truncate();
     $faker = Faker::create();
     for ($i = 1; $i <= 30; $i++) {
         Book::create(['title' => $faker->sentence(), 'description' => $faker->sentence(), 'author' => $faker->name]);
     }
 }
Ejemplo n.º 4
0
 public function create($request)
 {
     \DB::beginTransaction();
     $user = \Auth::user();
     $book = Book::create($request->all());
     $book->product()->create($request->all());
     $book->product->organizations()->attach($user->organization->id, ['dewey_code' => $request['dewey_code'], 'quantity' => $request['quantity'], 'cat_id' => $request['cat_id'], 'user_id' => $user->id, 'edited_by' => $user->id]);
     $book->authors()->attach($request['author-list']);
     $item = Item::find($book->product->orgcreate()->first()->pivot->id);
     $item->tags()->attach($request['tag-list']);
     \DB::commit();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $tolkien = Author::create(['name' => 'J.R.R. Tolkien', 'date_of_birth' => '1892-01-03']);
     Book::create(['title' => 'The Hobbit', 'publication_date' => '1937-09-21', 'isbn' => '9780582186552', 'author_id' => $tolkien->id]);
     Book::create(['title' => 'The Silmarillion', 'publication_date' => '1977-09-15', 'isbn' => '9780345325815', 'author_id' => $tolkien->id]);
     $karpyshyn = Author::create(['name' => 'Drew Karpyshyn', 'date_of_birth' => '1971-07-28']);
     Book::create(['title' => 'The Old Republic: Revan', 'publication_date' => '2011-11-15', 'isbn' => '9780857689009', 'author_id' => $karpyshyn->id]);
     Book::create(['title' => 'The Old Republic: Annihilation', 'publication_date' => '2012-11-13', 'isbn' => '9780345529411', 'author_id' => $karpyshyn->id]);
     $salvatore = Author::create(['name' => 'R.A. Salvatore', 'date_of_birth' => '1959-01-20']);
     Book::create(['title' => 'Homeland', 'publication_date' => '2004-03-01', 'isbn' => '9780786931231', 'author_id' => $salvatore->id]);
     Book::create(['title' => 'Attack of the Clones', 'publication_date' => '2003-04-01', 'isbn' => '9780345428820', 'author_id' => $salvatore->id]);
 }
Ejemplo n.º 6
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required|string|max:255', 'author' => 'required|string|max:255', 'barcode' => 'required|string|max:255', 'name' => 'required|string|max:255', 'email' => 'required|email|max:255']);
     try {
         $book = Book::create($request->all());
         $book->status = 'borrowed';
         $book->borrowed_at = new \DateTime();
         $book->save();
     } catch (\Exception $e) {
         return redirect()->back()->withErrors(['An unknown error has occurred while attempting to save this record']);
     }
     return redirect(action('BookController@index'))->with('success', ['The record was successfully saved']);
 }
Ejemplo n.º 7
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //Validate the Request
     $this->validate($request, ['title' => 'required', 'subject_id' => 'required|numeric', 'coverImage' => 'image', 'book' => 'mimes:pdf']);
     $request['uploaded_by'] = Auth::user()->id;
     if ($request->hasFile('coverImage')) {
         $imageName = str_slug($request['title']) . '_' . Auth::user()->id . '.' . $request['coverImage']->getClientOriginalExtension();
         $location = 'uploads/Books/' . $request['subject_name'] . '/' . $request['title'] . '/';
         $request['coverImage']->move($location, $imageName);
         $imageUrl = url($location . $imageName);
         $request['image'] = $imageUrl;
     }
     if ($request->hasFile('book')) {
         $bookName = str_slug($request['title']) . '.' . $request['book']->getClientOriginalExtension();
         $location = 'uploads/Books/' . $request['subject_name'] . '/' . $request['title'] . '/';
         $request['book']->move($location, $bookName);
         $bookUrl = url($location . $bookName);
         $request['book_url'] = $bookUrl;
     }
     Book::create($request->all());
     \Session::flash('flash_message', 'Book Created Successfully!');
     \Session::flash('flash_message_level', 'success');
     return Redirect::back();
 }
Ejemplo n.º 8
0
 /**
  * Add new book to database.
  * @param [array] $data array data from request
  * @return [type]  $book object book model which has just created
  */
 public function addNewBook($data)
 {
     $book = Book::create(['title' => $data['title'], 'bookurl' => $data['bookurl'], 'language_id' => 1, 'avatar' => 'question-mark.png', 'diravatar' => 'question-mark.png']);
     DB::table('book_author')->insert(['book_id' => $book->id, 'author_id' => Auth::user()->id, 'is_main' => 1, 'is_accepted' => 1]);
     Price::create(['item_id' => 'bo|' . $book->id, 'minimumprice' => 0, 'suggestedprice' => 0]);
     return $book;
 }
Ejemplo n.º 9
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['book_title' => 'required|string|max:500|unique:books,title', 'book_author_name' => 'required|string', 'book_nb_pages' => 'required|integer']);
     $book = Book::create(['title' => $request->input('book_title'), 'author' => $request->input('book_author_name'), 'num_pages' => $request->input('book_nb_pages')]);
     return response(['book' => $book], 201)->header('Location', '/api/books/' . $book->id);
 }
Ejemplo n.º 10
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function createBook(StoreBookPostRequest $request)
 {
     if (Input::hasFile('download_link')) {
         // upload path
         $destinationPath = 'uploads/';
         $download_link = Input::file('download_link');
         // renameing image
         $fileName = rand(11111, 99999) . '-' . $download_link->getClientOriginalName();
         $download_link->move($destinationPath, $fileName);
     }
     if ($book_id = Input::get('book_id')) {
         $book = Book::find($book_id);
         $book->book_name = Input::get('book_name');
         $book->book_slug = str_slug(Input::get('book_name'), '-');
         $book->author = Input::get('author');
         $book->publication = Input::get('publication');
         $book->description = Input::get('description');
         $book->rate = Input::get('rate');
         $book->discount = Input::get('discount');
         $book->discount_qty = Input::get('discount_qty');
         $book->book_type_id = Input::get('book_type_id');
         $book->category_id = Input::get('category_id');
         if (Input::hasFile('download_link')) {
             $book->download_link = $destinationPath . $fileName;
         }
         $book->show_home_page = Input::get('show_home_page');
         $book->save();
         $success = 'Book updated successfully';
     } else {
         $book = Input::get();
         $book['book_slug'] = str_slug(Input::get('book_name'));
         $book['download_link'] = $destinationPath . $fileName;
         Book::create($book);
         $success = 'Book created successfully';
     }
     return redirect('admin/book/dashboard')->with('success', $success);
 }