예제 #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, PhotoParent $photoParent)
 {
     $photoParent->update($request->except('images', 'q'));
     return redirect()->route('admin.photoParent.show', $photoParent);
 }
예제 #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, PhotoParent $photoParent)
 {
     $photoParent->update($request->except('images', 'q', 'status'));
     //        dd($request->images);
     //        dd($_FILES["images"]);
     if ($request->hasFile('images')) {
         $files = Input::file('images');
         $result = array();
         $uploadcount = 0;
         foreach ($files as $key => $file) {
             //            if($key > 1)
             //            {
             $storage = \Storage::disk('public');
             $destinationPath = 'froala/uploads';
             $storage->makeDirectory($destinationPath);
             $filename = time() . $key . '.' . $file->getClientOriginalExtension();
             //                $name2 = $photoParent->id().$btw.'_big.'.$file->getClientOriginalExtension();
             //                $upload_success = $file->move($destinationPath, $filename);
             Image::make($_FILES['images']['tmp_name'][$key])->heighten(600)->save($destinationPath . '/' . $filename);
             $file_array = array();
             $file_array = array_collapse([$file_array, ['id' => $key + 1, 'name' => $filename]]);
             $result = array_add($result, $key, $file_array);
             $jsonresult = json_encode($result);
             $photoParent->images = $jsonresult;
             $photoParent->save();
             $uploadcount++;
             //            } // end if
         }
     }
     if ($request->hasFile('status')) {
         $file = $request->file('status');
         $dir = 'img/thumbnail';
         $btw = time();
         $name = $photoParent->id() . $btw . '.' . $file->getClientOriginalExtension();
         $name2 = $photoParent->id() . $btw . '_big.' . $file->getClientOriginalExtension();
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         //            Image::make($_FILES['status']['tmp_name'])->resize(250, 150)->save($dir.'/'.$name);
         Image::make($_FILES['status']['tmp_name'])->fit(250, 150)->save($dir . '/' . $name);
         Image::make($_FILES['status']['tmp_name'])->fit(300, 180)->save($dir . '/' . $name2);
         $photoParent->status = $dir . '/' . $name;
         $photoParent->thumbnail_big = $dir . '/' . $name2;
         $photoParent->save();
     }
     // start count how many uploaded
     return redirect()->route('admin.photoParent.show', $photoParent);
 }