Page 66 - Laravel5_v1
P. 66

* Show the form for creating a new resource.
                  *
                  * @return \Illuminate\Http\Response
                  */
                 public function create() {
                     return view('books.create');
                 }

                 /**
                  * Store a newly created resource in storage.
                  *
                  * @param  \Illuminate\Http\Request  $request
                  * @return \Illuminate\Http\Response
                  */
                 public function store(StoreBooksRequest $request) {
                     $book = new Books();
                     $book->title = $request->title;
                     $book->price = $request->price;
                     $book->typebooks_id = $request->typebooks_id;
                     if ($request->hasFile('image')) {
                         $filename = str_random(10) . '.' . $request->file('image')-
             >getClientOriginalExtension();
                         $request->file('image')->move(public_path() . '/images/', $filename);
                         Image::make(public_path() . '/images/' . $filename)->resize(50, 50)-
             >save(public_path() . '/images/resize/' . $filename);
                         $book->image = $filename;
                     } else {
                         $book->image = 'nopic.jpg';
                     }
                     $book->save();
                     return redirect()->action('BooksController@index');
                 }

                 /**
                  * Display the specified resource.
                  *
                  * @param  int  $id
                  * @return \Illuminate\Http\Response
                  */
                 public function show($id) {

                 }

                 /**
                  * Show the form for editing the specified resource.
                  *
                  * @param  int  $id
                  * @return \Illuminate\Http\Response
   61   62   63   64   65   66   67   68   69   70   71