/** * Update the specified resource in storage. * * @param App\Http\Requests\PostUpdateRequest $request * @param int $id * @return Response */ public function putUpdate(CategoryRequest $request, $id) { $getdata = $request->all(); $userdet = array(); if ($request->hasFile('banner_img')) { $file = $request->file('banner_img'); $bannerimgNm = "banner_" . date("ymdHis") . '.' . $file->getClientOriginalExtension(); $realPath = base_path() . '/public/uploaded/category/'; $resizePath = base_path() . '/public/uploaded/category/thumb/' . $bannerimgNm; $openMakePath = $realPath . $bannerimgNm; $request->file('banner_img')->move($realPath, $bannerimgNm); Image::make($openMakePath)->resize(400, 500)->save($resizePath); } else { $bannerimgNm = $getdata['oldbannerimage']; } if ($request->hasFile('background_img')) { $file = $request->file('background_img'); $bckgndimgNm = "backgnd_" . date("ymdHis") . '.' . $file->getClientOriginalExtension(); $realPath = base_path() . '/public/uploaded/category/'; $resizePath = base_path() . '/public/uploaded/category/thumb/' . $bckgndimgNm; $openMakePath = $realPath . $bckgndimgNm; $request->file('background_img')->move($realPath, $bckgndimgNm); Image::make($openMakePath)->resize(200, 300)->save($resizePath); } else { $bckgndimgNm = $getdata['oldbackgndimg']; } if ($request->hasFile('icon_img')) { $file = $request->file('icon_img'); $iconimgNm = "icon_" . date("ymdHis") . '.' . $file->getClientOriginalExtension(); $realPath = base_path() . '/public/uploaded/category/'; $resizePath = base_path() . '/public/uploaded/category/thumb/' . $iconimgNm; $openMakePath = $realPath . $iconimgNm; $request->file('icon_img')->move($realPath, $iconimgNm); Image::make($openMakePath)->resize(50, 50)->save($resizePath); } else { $iconimgNm = $getdata['oldiconimage']; } $active = isset($getdata['active']) ? $getdata['active'] : '0'; $hidden = isset($getdata['is_hidden']) ? $getdata['is_hidden'] : '0'; $userdet['_token'] = $getdata['_token']; $userdet['name'] = $getdata['name']; $userdet['category_slug'] = $getdata['slug']; $userdet['background_img'] = $bckgndimgNm; $userdet['banner_img'] = $bannerimgNm; $userdet['icon_img'] = $iconimgNm; $userdet['active'] = $active; $userdet['is_hidden'] = $hidden; $this->category_gestion->update($userdet, $id); $request->session()->flash('alert-success', 'Category has been updated successfully'); return redirect('admin/category'); exit; }