/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $media = Media::create($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; } $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.index'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { Media::create($request->except('q')); return redirect()->route('admin.media.index'); }