Beispiel #1
0
 public function store(SettingRequest $request)
 {
     $logo = array('image' => $request->file('logo'));
     $favicon = array('image' => $request->file('favicon'));
     $rules = array('image' => 'required');
     //mimes:jpeg,bmp,png and for max size max:10000
     // doing the validation, passing post data, rules and the messages
     $validatorLogo = Validator::make($logo, $rules);
     $validatorFavicon = Validator::make($favicon, $rules);
     $this->setting->createOrUpdate($request->all());
     if ($request->file('logo') !== null) {
         if ($validatorLogo->fails()) {
             // send back to the page with the input data and errors
             return Redirect::to('upload')->withInput()->withErrors($validatorLogo);
         } else {
             // checking file is valid.
             if ($request->file('logo')->isValid()) {
                 $filename = 'logo.' . $request->file('logo')->getClientOriginalExtension();
                 $destinationLogo = public_path('images/' . $filename);
                 Image::make($request->file('logo')->getRealPath())->save($destinationLogo);
                 DB::table('setting__settings')->where('name', 'core::logo')->update(['plainValue' => 'images/' . $filename]);
             }
         }
     }
     if ($request->file('favicon') !== null) {
         if ($validatorFavicon->fails()) {
             // send back to the page with the input data and errors
             return Redirect::to('upload')->withInput()->withErrors($validatorLogo);
         } else {
             // checking file is valid.
             if ($request->file('favicon')->isValid()) {
                 $filename = 'favicon.' . $request->file('favicon')->getClientOriginalExtension();
                 $destinationFavicon = public_path('images/' . $filename);
                 Image::make($request->file('favicon')->getRealPath())->save($destinationFavicon);
                 DB::table('setting__settings')->where('name', 'core::favicon')->update(['plainValue' => 'images/' . $filename]);
             }
         }
     }
     flash(trans('setting::messages.settings saved'));
     return redirect()->route('dashboard.module.settings', [$this->session->get('module', 'Core')]);
 }
 public function store(SettingRequest $request)
 {
     $this->setting->createOrUpdate($request->all());
     flash(trans('setting::messages.settings saved'));
     return redirect()->route('dashboard.module.settings', [$this->session->get('module', 'Core')]);
 }