Page 73 - Laravel5_v1
P. 73

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
                      */
                     public function edit($id) {
                         $book = Books::findOrFail($id);
                         return view('books.edit', ['book' => $book]);
                     }

                     /**
                      * Update the specified resource in storage.
                      *
                      * @param  \Illuminate\Http\Request  $request
                      * @param  int  $id
                      * @return \Illuminate\Http\Response
                      */
                     public function update(StoreBooksRequest $request, $id) {
                        $book = Books::find($id);
                         /* $book->title = $request->title;
                           $book->price = $request->price;
                           $book->typebooks_id = $request->typebooks_id;
   68   69   70   71   72   73   74   75   76   77   78