コード例 #1
0
ファイル: MediaController.php プロジェクト: joogazyn/ktrk
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, Media $media)
 {
     $media->update($request->except('q'));
     return redirect()->route('admin.media.show', $media);
 }
コード例 #2
0
ファイル: MediaController.php プロジェクト: shady11/ktrk-1
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, Media $media)
 {
     $media->update($request->except('q', 'thumbnail', 'hitnumber'));
     if ($request->input('hitnumber')) {
         $hitnumber = $request->input('hitnumber');
         $allMedias = \Model\Media\ModelName::where('hitnumber', '=', $hitnumber)->get();
         foreach ($allMedias as $key => $value) {
             $value->hitnumber = 0;
             $value->save();
         }
         $media->hitnumber = $hitnumber;
         $media->save();
     }
     if ($request->hasFile('thumbnail')) {
         $file = $request->file('thumbnail');
         $dir = 'img/thumbnail';
         $btw = time();
         $name = $media->id() . $btw . '.' . $file->getClientOriginalExtension();
         $name2 = $media->id() . $btw . '_big.' . $file->getClientOriginalExtension();
         //            $manager = new ImageManager(array('driver' => 'imagick'));
         $storage = \Storage::disk('public');
         $storage->makeDirectory($dir);
         Image::make($_FILES['thumbnail']['tmp_name'])->fit(250, 150)->save($dir . '/' . $name);
         Image::make($_FILES['thumbnail']['tmp_name'])->fit(500, 300)->save($dir . '/' . $name2);
         $media->thumbnail = $dir . '/' . $name;
         $media->thumbnail_big = $dir . '/' . $name2;
         $media->save();
     }
     return redirect()->route('admin.media.show', $media);
 }