/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('books')->delete();
     Book::create(['title' => 'Eugenii Onegin', 'isbn' => '09374726342', 'price' => '10.40', 'cover' => 'onegin.jpg', 'author_id' => '1']);
     Book::create(['title' => 'Stihi', 'isbn' => '5555555555', 'price' => '8.25', 'cover' => 'esenin_stihi.jpg', 'author_id' => '2']);
     Book::create(['title' => 'Angels and demons', 'isbn' => '1111111111', 'price' => '15.99', 'cover' => 'brown_angels.jpg', 'author_id' => '3']);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     //
     $book = Request::all();
     Book::create($book);
     return redirect('books');
 }
 public function run()
 {
     DB::table('books')->delete();
     Book::create(['title' => 'A Tale of Two Cities', 'author' => 'Charles Dickens', 'year' => '1859']);
     Book::create(['title' => 'The Lord of the Rings', 'author' => 'J. R. R. Tolkien', 'year' => '1954']);
     Book::create(['title' => 'And Then There Were None', 'author' => 'Agatha Christie', 'year' => '1939']);
     Book::create(['title' => 'The Hobbit', 'author' => 'J. R. R. Tolkien', 'year' => '1937']);
     Book::create(['title' => 'She: A History of Adventure', 'author' => 'H. Rider Haggard', 'year' => '1887']);
     Book::create(['title' => 'The Lion the Witch and the Wardrobe', 'author' => 'C. S. Lewis', 'year' => '1950']);
     Book::create(['title' => 'The Da Vinci Code', 'author' => 'Dan Brown', 'year' => '2003']);
     Book::create(['title' => 'The Catcher in the Rye', 'author' => 'J. D. Salinger', 'year' => '1951']);
     Book::create(['title' => 'Lolita', 'author' => 'Vladimir Nabokov', 'year' => '1955']);
     Book::create(['title' => 'Anne of Green Gables', 'author' => 'Lucy Maud Montgomery', 'year' => '1908']);
     Book::create(['title' => 'The Name of the Rose', 'author' => 'Umberto Eco', 'year' => '1980']);
     Book::create(['title' => 'The Eagle Has Landed', 'author' => 'Jack Higgins', 'year' => '1975']);
     Book::create(['title' => 'Watership Down', 'author' => 'Richard Adams', 'year' => '1972	']);
     Book::create(['title' => 'The Ginger Man', 'author' => 'J. P. Donleavy', 'year' => '1955']);
     Book::create(['title' => 'The Bridges of Madison County', 'author' => 'Robert James Waller', 'year' => '1991']);
     Book::create(['title' => 'The Tale of Peter Rabbit', 'author' => 'Beatrix Potter', 'year' => '1902']);
     Book::create(['title' => 'Harry Potter and the Deathly Hallows', 'author' => 'J. K. Rowling', 'year' => '2007']);
     Book::create(['title' => 'Jonathan Livingston Seagull', 'author' => 'Richard Bach', 'year' => '1970']);
     Book::create(['title' => 'A Message to Garcia', 'author' => 'Elbert Hubbard', 'year' => '1899']);
     Book::create(['title' => 'Flowers in the Attic', 'author' => 'V. C. Andrews', 'year' => '1979']);
     Book::create(['title' => 'War and Peace', 'author' => 'Leo Tolstoy', 'year' => '1869']);
     Book::create(['title' => 'The Adventures of Pinocchio', 'author' => 'Carlo Collodi', 'year' => '1881']);
     Book::create(['title' => 'Kane and Abel', 'author' => 'Jeffrey Archer', 'year' => '1979']);
     Book::create(['title' => 'To Kill a Mockingbird', 'author' => 'Harper Lee', 'year' => '1960']);
     Book::create(['title' => 'Valley of the Dolls', 'author' => 'Jacqueline Susann', 'year' => '1966']);
     Book::create(['title' => 'Gone with the Wind', 'author' => 'Margaret Mitchell', 'year' => '1936']);
     Book::create(['title' => 'The Diary of a Young Girl', 'author' => 'Anne Frank', 'year' => '1947']);
     Book::create(['title' => 'One Hundred Years of Solitude', 'author' => 'Gabriel Garcia Marquez', 'year' => '1967']);
     Book::create(['title' => 'The Thorn Birds', 'author' => 'Colleen McCullough', 'year' => '1977']);
     Book::create(['title' => 'The Revolt of Mamie Stover', 'author' => 'William Bradford Huie', 'year' => '1951']);
     Book::create(['title' => 'The Girl with the Dragon Tattoo', 'author' => 'Stieg Larsson', 'year' => '2005']);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateBookRequest $request)
 {
     $user = \Auth::User();
     if (!$user) {
         return view('auth.login')->withErrors('You are not loged in, please loged in !');
     }
     $book = $request->bookFillData();
     $book['user_id'] = $user->id;
     $book['published_at'] = Carbon::parse($request->get('published_at'))->format('Y-m-d');
     $fileSizeValidation = \Config::get('library.image_file_size');
     $newBook = Book::create($book);
     $newBook->syncAuthors($request->get('authors'));
     $this->manager->createDirectory($newBook->id);
     $file = $_FILES['image'];
     if ($file['size'] > 0) {
         // Additional image validation
         if (!starts_with($file['type'], 'image/')) {
             return Redirect::action('BookController@create')->withErrors('Invalid file format, please use image !');
         }
         $fileSize = $file['size'] / 1024;
         if ($fileSize > $fileSizeValidation) {
             return Redirect::action('BookController@create')->withErrors('The image may not be greater than ' . $fileSizeValidation . ' kilobytes. ');
         }
         $img = Image::make($_FILES['image']['tmp_name']);
         $img->resize(140, 140);
         $img->save('.' . \Config::get('library.uploads.webpath') . DIRECTORY_SEPARATOR . $newBook->id . '/cover.jpg');
     }
     return redirect::action('BookController@index')->withSuccess("The book with title '{$newBook->title}' was created.");
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['isbn' => 'required', 'title' => 'required', 'author' => 'required', 'publisher' => 'required', 'language' => 'required']);
     $input = $request->all();
     Book::create($input);
     Session::flash('flash_message', 'Book successfully added!');
     return redirect()->back();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\BooksRequest $r)
 {
     $book = $r->all();
     $book['addedDate'] = Carbon::now();
     $book['userAdd'] = Auth::user()->id;
     Book::create($book);
     return redirect('/home');
 }
Beispiel #7
0
 public function store(Requests\User $request)
 {
     $all = $request->all();
     \App\Book::create($all);
     echo '<pre>';
     print_r($all);
     die;
     return redirect('books');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Requests\CreateBookRequest $request)
 {
     $input = $request->all();
     if (\App\Book::create($input)) {
         return response()->json(['msg' => 'success'], 201);
     } else {
         return response()->json(['msg' => 'error', 'error' => 'cannot create record'], 400);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('lends')->delete();
     DB::table('users')->delete();
     User::create(['id' => '1', 'name' => '郑文凯', 'email' => '*****@*****.**', 'password' => Hash::make('123'), 'is_admin' => 1, 'reserve_num' => 1]);
     User::create(['id' => '2', 'name' => '陈翔宇', 'email' => '*****@*****.**', 'password' => Hash::make('1'), 'is_admin' => 0, 'reserve_num' => 10]);
     DB::table('books')->delete();
     Book::create(['id' => '1', 'book_name' => '书名', 'author' => '作者', 'ISBN' => '123456', 'press_name' => '出版社', 'press_date' => '123456', 'url' => '链接', 'in_use' => '0']);
     Lend::create(['user_id' => '2', 'book_id' => '1', 'lend_date' => '1234', 'due_date' => '2345', 'return_date' => '3456', 'continued' => '1', 'is_returned' => '0']);
 }
Beispiel #10
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('books')->insert(['name' => 'test book1', 'type' => 'islamic', 'description' => 'good book', 'published_at' => Carbon\Carbon::now(), 'price' => 1000.0, 'pages' => 343, 'author' => 'Amina Nisar', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     Book::create(['name' => 'zoo2', 'type' => 'general', 'description' => 'good book', 'published_at' => Carbon\Carbon::now(), 'price' => 10444.0, 'pages' => 3463, 'author' => 'Amina Nisar']);
     Book::create(['name' => 'history3', 'type' => 'general', 'description' => 'good book', 'published_at' => Carbon\Carbon::now(), 'price' => 10444.0, 'pages' => 3463, 'author' => 'Amina Nisar']);
     Book::create(['name' => 'hello world4', 'type' => 'general', 'description' => 'good book', 'published_at' => Carbon\Carbon::now(), 'price' => 10444.0, 'pages' => 3463, 'author' => 'Amina Nisar']);
     Book::create(['name' => 'Databases5', 'type' => 'general', 'description' => 'good book', 'published_at' => Carbon\Carbon::now(), 'price' => 10444.0, 'pages' => 3463, 'author' => 'Amina Nisar']);
     Book::create(['name' => 'seeders6', 'type' => 'general', 'description' => 'good book', 'published_at' => Carbon\Carbon::now(), 'price' => 10444.0, 'pages' => 3463, 'author' => 'Amina Nisar']);
     Book::create(['name' => 'helper7', 'type' => 'general', 'description' => 'good book', 'published_at' => Carbon\Carbon::now(), 'price' => 10444.0, 'pages' => 3463, 'author' => 'Amina Nisar']);
     Book::create(['name' => 'future8', 'type' => 'general', 'description' => 'good book', 'published_at' => Carbon\Carbon::now(), 'price' => 10444.0, 'pages' => 3463, 'author' => 'Amina Nisar']);
     Book::create(['name' => 'programming9', 'type' => 'general', 'description' => 'good book', 'published_at' => Carbon\Carbon::now(), 'price' => 10444.0, 'pages' => 3463, 'author' => 'Amina Nisar']);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function postStore(Request $request)
 {
     //usando request
     $data = $request->all();
     //usando metodo create (obs: é necessario ter o metodo filabo)
     /*$data = ['title' => 'Game of Thrones', 'description' => 'Livro massa pra caramba'];*/
     Book::create($data);
     //usando o save
     /*$book->title = 'Alto da barca do Céu';
       $book->description = 'Descrição de livro';
       $book->save();*/
     return redirect('books');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $input = $request->all();
     //dd($input);
     if (isset($input['filepath'])) {
         $imgPath = $this->imageUpload($input['filepath']);
         $input['filepath'] = $imgPath;
     } else {
         $input['filepath'] = "modules/image.jpeg";
     }
     Book::create($input);
     return redirect('BARD_book')->with('status', 'Create successfully');
 }
 /**
  * @param StoreBookPostRequest $request
  * @return mixed
  */
 public function save(StoreBookPostRequest $request)
 {
     $bookId = Input::get('book_id');
     if ($bookId) {
         $book = Book::find($bookId);
         $book->update(Input::all());
     } else {
         $book = Book::create(Input::all());
         $this->notifyUsers($book);
     }
     if (!$book) {
         return Redirect::back()->with('message', 'Something wrong happened while saving your model')->withInput();
     }
     return Redirect::route('books')->with('message', sprintf('Book "%s" saved', $book->title));
 }
Beispiel #14
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $book = Request::all();
     $destinationPath = 'uploads/img/';
     // upload path
     $thumb_path = 'uploads/img/thumb/';
     $extension = Input::file('image')->getClientOriginalExtension();
     // getting image extension
     $fileName = rand(111111111, 999999999) . '.' . $extension;
     // renameing image
     Input::file('image')->move($destinationPath, $fileName);
     // uploading file to given path
     // $this->create_thumbnail($thumb_path,$fileName,$extension);
     $book['image'] = $fileName;
     Book::create($book);
     Session::flash('success', 'Upload successfully');
     return redirect('admin/book');
 }
 public function store()
 {
     if (\Request::file('cover')->isValid()) {
         $file = \Request::file('cover');
         $destinationPath = './images';
         //public_path() .
         $extension = \Request::file('cover')->getClientOriginalExtension();
         $filename = rand(1111111, 9999999) . '.' . $extension;
         $file->move($destinationPath, $filename);
         $image = \App\Image::create(['path' => './images/' . $filename, 'description' => 'main']);
     } else {
         return redirect()->back()->withInput()->with('message', 'image file invalid');
     }
     $book = \App\Book::create(['title' => \Request::get('title'), 'isbn' => \Request::get('isbn'), 'price' => \Request::get('price'), 'cover' => $filename]);
     $book->images()->attach($image->id);
     $book->Author()->attach(\Request::get('author_id'));
     $book->categories()->attach(\Request::get('category'));
     return redirect('./admin/products')->with('message', 'product created');
 }
Beispiel #16
0
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        DB::table('books')->delete();
        Book::create(array('title' => 'Head First Design Patterns', 'authors' => 'Eric Freeman, Elisabeth Freeman, Bert Bates, Kathy Sierra', 'approved' => false, 'summary' => 'A Brain-Friendly Guide', 'file_path' => 'Refactoring - Improving the Design of Existing Code (2002, Kent Beck, Addison Wesley).pdf'));
        Book::create(array('title' => 'Software Systems Architecture', 'authors' => 'Nick Rozanski, Eoin Woods', 'approved' => true, 'summary' => 'Working With Stakeholders Using Viewpoints and Perspectives', 'file_path' => 'Refactoring - Improving the Design of Existing Code (2002, Kent Beck, Addison Wesley).pdf'));
        Book::create(array('title' => 'Refactoring: Improving the Design of Existing Code', 'authors' => 'Martin Fowler, Kent Beck, John Brant, William Opdyke, don Roberts', 'approved' => false, 'summary' => 'Improving the Design of Existing Code shows how refactoring can make object-oriented code simpler and easier
to maintain.', 'file_path' => 'Refactoring - Improving the Design of Existing Code (2002, Kent Beck, Addison Wesley).pdf'));
        Book::create(array('title' => 'Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming', 'authors' => 'Maurice Sharp, Erica Sadun, Rod Strougo', 'approved' => false, 'summary' => 'Computer Programming', 'file_path' => 'Refactoring - Improving the Design of Existing Code (2002, Kent Beck, Addison Wesley).pdf'));
        Book::create(array('title' => 'Introduction to Networks Companion Guide', 'authors' => 'Cisco Networking Academy', 'approved' => true, 'summary' => 'Networking', 'file_path' => 'Refactoring - Improving the Design of Existing Code (2002, Kent Beck, Addison Wesley).pdf'));
        Book::create(array('title' => 'Calculus: Early Transcendentals', 'authors' => 'James Stewart', 'approved' => true, 'summary' => 'Mathematics', 'file_path' => 'Refactoring - Improving the Design of Existing Code (2002, Kent Beck, Addison Wesley).pdf'));
        Book::create(array('title' => 'Security+ Guide to Network Security Fundamentals', 'authors' => 'Mark Ciampa', 'approved' => true, 'summary' => 'Networking', 'file_path' => 'Refactoring - Improving the Design of Existing Code (2002, Kent Beck, Addison Wesley).pdf'));
        Book::create(array('title' => 'Calculus: An Applied Approach', 'authors' => 'Ron Larson', 'approved' => true, 'summary' => 'Mathematics', 'file_path' => 'Refactoring - Improving the Design of Existing Code (2002, Kent Beck, Addison Wesley).pdf'));
        Book::create(array('title' => 'When Things Start to Think', 'authors' => 'Neil Gershenfeld', 'approved' => true, 'summary' => 'Artificial Intelligence (AI)', 'file_path' => 'Refactoring - Improving the Design of Existing Code (2002, Kent Beck, Addison Wesley).pdf'));
        Book::create(array('title' => 'College Algebra', 'authors' => 'Ron Larson', 'approved' => true, 'summary' => 'Mathematics', 'file_path' => 'Refactoring - Improving the Design of Existing Code (2002, Kent Beck, Addison Wesley).pdf'));
        Book::create(array('title' => 'Next Fifty Years: Science in the First Half of the Twenty-First Century', 'authors' => 'John Brockman', 'approved' => true, 'summary' => 'Artificial Intelligence (AI)', 'file_path' => 'Refactoring - Improving the Design of Existing Code (2002, Kent Beck, Addison Wesley).pdf'));
        Book::create(array('title' => 'Computer Organization and Design: The Hardware/Software Interface', 'authors' => 'David A. Patterson', 'approved' => true, 'summary' => 'Hardware', 'file_path' => 'Refactoring - Improving the Design of Existing Code (2002, Kent Beck, Addison Wesley).pdf'));
        Book::create(array('title' => 'Introducing Microsoft SQL Server 2012', 'authors' => 'Ross Mistry, Stacia Misner', 'approved' => true, 'summary' => 'Database Management', 'file_path' => 'Refactoring - Improving the Design of Existing Code (2002, Kent Beck, Addison Wesley).pdf'));
        Book::create(array('title' => 'A Practical Guide to Linux Commands, Editors, and Shell Programming', 'authors' => 'Mark G. Sobell', 'approved' => true, 'summary' => 'Operating system', 'file_path' => 'Refactoring - Improving the Design of Existing Code (2002, Kent Beck, Addison Wesley).pdf'));
        Book::create(array('title' => 'Programming in Objective-C', 'authors' => 'Stephen G. Kochan', 'approved' => true, 'summary' => 'Programming', 'file_path' => 'Refactoring - Improving the Design of Existing Code (2002, Kent Beck, Addison Wesley).pdf'));
        Book::create(array('title' => 'Introduction to Java Programming, Comprehensive Version', 'authors' => 'Y. Daniel Liang', 'approved' => true, 'summary' => 'Programming', 'file_path' => 'Refactoring - Improving the Design of Existing Code (2002, Kent Beck, Addison Wesley).pdf'));
        Book::create(array('title' => 'JavaScript and JQuery: Interactive Front-End Web Development', 'authors' => 'Jon Duckett', 'approved' => true, 'summary' => 'WWW and Internet', 'file_path' => 'Refactoring - Improving the Design of Existing Code (2002, Kent Beck, Addison Wesley).pdf'));
    }
Beispiel #17
0
 public function insert($data)
 {
     // Validating data
     $validator = Validator::make($data, Book::createrules());
     // If there are no errors in data
     if (!$validator->fails()) {
         // Create Book
         $book = Book::create($data);
         // Checking if there are any chapters
         if (isset($data['chapters']) && sizeof($data['chapters']) > 0) {
             // Looping through chapters
             foreach ($data['chapters'] as $chapter) {
                 // Creating the chapter
                 $this->chaptersService->insert($book->id, $chapter);
             }
         }
         // Passing data to response service
         return $this->responseService->returnMessage($book, 'Book was not Inserted.');
     } else {
         // Data has errors
         // Passing errors to response service
         return $this->responseService->errorMessage($validator->errors()->all());
     }
 }
Beispiel #18
0
 /**
  * Store a newly created book resource in storage.
  *
  * @param BookRequest $request App\Http\Requests\BookRequest request
  *
  * @return \Illuminate\Http\Response
  */
 public function store(BookRequest $request)
 {
     $book = Book::create($request->only(['title', 'description']));
     return redirect()->action('BooksController@index')->withSuccess("Książka \"{$book->title}\" została dodana");
 }
Beispiel #19
0
 /**
  * Store a book to the library
  *
  * @param AddBookRequest $request
  * @return Response
  */
 public function store(AddBookRequest $request)
 {
     $author = $this->getAuthor(Input::get('author')['first_name'], Input::get('author')['last_name']);
     $publisher = $this->getPublisher(Input::get('publisher')['name']);
     $path = $this->imageUpload($request);
     $book = Book::create(['title' => $request->title, 'author_id' => $author->id, 'publisher_id' => $publisher->id, 'isbn' => $request->isbn, 'image' => $path, 'summary' => $request->summary, 'year' => $request->year, 'edition' => $request->edition, 'quantity' => $request->quantity]);
     SearchIndex::upsertToIndex($book);
     flash()->success('Book successfully added!');
     return redirect('admin/add');
 }
 public function createBook(Request $request)
 {
     $Book = Book::create($request->all());
     return response()->json($Book);
 }
Beispiel #21
0
 public function create()
 {
     $b = Book::create(['name' => 'Quran', 'description' => 'for Muslims to read', 'published_at' => '', 'type' => 'Islamic', 'author' => 'Muhammad', 'pages' => '398', 'price' => '100.89']);
 }
    $title = 'Eze goes to College';
    $pages_count = 800;
    $price = 15.5;
    $description = 'This is a very interesting book about Eze going to College and killing it';
    $author_id = 1;
    $publisher_id = 1;
    // Method 1 of inserting records into the database via a Model - Mass Assignment
    $book = new \App\Book(['title' => $title, 'pages_count' => $pages_count, 'price' => $price, 'description' => $description, 'author_id' => $author_id, 'publisher_id' => $publisher_id]);
    $book->save();
    // You have to call the save method here if using Method 1 technique
    // Use either of them to insert records into the database
    // For security issues it won't allow you create those records just like that, so...
    // Make sure you have properties $fillable or $guarded in your Model
    // e.g protected $fillable  = ['title','pages_count','price','description','author_id','publisher_id']
    // Method 2 of inserting records into the database via a Model - Mass Assignment
    $book = \App\Book::create(['title' => $title, 'price' => $price, 'pages_count' => $pages_count, 'description' => $description, 'author_id' => $author_id, 'publisher_id' => $publisher_id]);
    echo "Done....";
});
Route::get('book_get_all', function () {
    return \App\Book::all();
});
Route::get('book_get_2', function () {
    return \App\Book::findOrFail(2);
});
Route::get('book_get_3', function () {
    $results = \App\Book::find(3);
    echo $results;
});
Route::get('book_get_where', function () {
    $result = \App\Book::where('pages_count', '<', 1000)->get();
    return $result;
Beispiel #23
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $input = $request->input();
     Book::create($input);
     return redirect('book/index');
 }
 public function store(BookRequest $request)
 {
     Book::create($request->all());
     return redirect('books');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $book = $request->all();
     \App\Book::create($book);
     return redirect('books');
 }