示例#1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(StoreRequest $request, Store $store)
 {
     $data = $request->all();
     if ($request->hasFile('img_pp')) {
         $file = $request->file('img_pp');
         $fileName = time() . '-' . $file->getClientOriginalName();
         $file->move('uploads', $fileName);
         $data['pp'] = $fileName;
     }
     if ($request->hasFile('img_cover')) {
         $file = $request->file('img_cover');
         $fileName = time() . '-' . $file->getClientOriginalName();
         $file->move('uploads', $fileName);
         $data['cover'] = $fileName;
     }
     $store->update($data);
     return redirect('store/' . $store->id);
 }