/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     // getting all of the post data
     $file = array('image' => Input::file('image'));
     // setting up rules
     $rules = array('image' => 'required');
     //mimes:jpeg,bmp,png and for max size max:10000
     // doing the validation, passing post data, rules and the messages
     $validator = Validator::make($file, $rules);
     Cache::flush();
     if ($validator->fails()) {
         // send back to the page with the input data and errors
         return Redirect::to('logos/create')->withInput()->withErrors($validator);
     } else {
         // checking file is valid.
         $url = $this->uploadFile(Input::file('image'));
         if ($url) {
             $input = array_except($request->all(), ['_method', '_token', 'image']);
             $input['url'] = $url;
             Logo::create($input);
             return redirect()->route('logos.index')->with('message', 'Logo created.')->with('message-class', 'success');
         } else {
             Session::flash('error', 'Uploaded file is not valid');
             return redirect()->route('logo')->with('message', 'Uploaded file is not valid.')->with('message-class', 'error');
         }
     }
 }
 /**
  * @param Request $request
  */
 public function profile_logo(Request $request)
 {
     $travel_company = Auth::travel_company_staff()->get()->travel_company;
     $destinationPath = null;
     if (App::environment() == 'local') {
         $destinationPath = base_path() . '/public/images/';
     } elseif (App::environment() == 'production') {
         $destinationPath = '/home/twokays/public_html/images/';
     }
     if ($request->file('file')->isValid()) {
         $file = $request->file('file');
         $ext = $file->getClientOriginalExtension();
         $destinationPath = $destinationPath;
         $fileName = str_slug($travel_company->name) . '_logo.' . $ext;
         $full_path = '/images/' . $fileName;
         $file->move($destinationPath, $fileName);
         // uploading file to given path
         $tcl = Logo::where('travel_company_id', $travel_company->id)->first();
         if (!$tcl) {
             Logo::create(['path' => $full_path, 'travel_company_id' => $travel_company->id]);
         } else {
             $tcl->update(['path' => $full_path]);
         }
         return $full_path;
     }
 }