/**
  * Store a newly created institution in storage.
  *
  * @return Response
  */
 public function store()
 {
     //$alldata = Input::all();/*   this gets all*/
     $data = Input::only('title', 'body', 'topcolor', 'topfontcolor', 'currentdi', 'extracomments');
     $data['logo'] = json_encode(Input::get('fileid'));
     // validation rules
     $rules = array('title' => 'required', 'logo' => 'required');
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     // @todo: I need to move the file out of tmp to someplace else.
     Institution::create($data);
     // @todo: route to the "show" of the institution
     return Redirect::route('institutions.index');
 }
Beispiel #2
0
 public function postNewCollege()
 {
     //verify the user input and create account
     $validator = Validator::make(Input::all(), array('Country' => 'required|exists:countrys,id', 'College_Name' => 'required|max:200|unique:institutions,name', 'Alias' => 'required|max:50', 'Pic' => 'image|max:3000'));
     if ($validator->fails()) {
         return Redirect::route('newcollege-get')->withErrors($validator)->withInput()->with('global', 'Sorry!! College details were not posted, please retry.');
     } else {
         $countryid = Input::get('Country');
         $collegename = Input::get('College_Name');
         $alias = Input::get('Alias');
         $file = Input::file('Pic');
         $photo = null;
         $user_id = Auth::user()->id;
         if ($file != null) {
             //photos validation
             $destinationPath = 'logos';
             $ext = $file->guessClientExtension();
             // Get real extension according to mime type
             $fullname = $file->getClientOriginalName();
             // Client file name, including the extension of the client
             $hashname = date('H.i.s') . '-' . md5($fullname) . '.' . $ext;
             // Hash processed file name, including the real extension
             $upload_success = $file->move($destinationPath, $hashname);
             //Set the photo path name to hashname
             $photo = $hashname;
         }
         //save college to the database
         $institution = Institution::create(array('user_id' => $user_id, 'country_id' => $countryid, 'name' => $collegename, 'alias' => $alias, 'photo' => $photo));
         if ($institution) {
             View::share('selectedcountryid', $institution->country_id);
             $countries = Country::where('id', '>', 0)->get();
             View::share('countries', $countries);
             $colleges = Institution::where('id', '>', 0)->get();
             View::share('colleges', $colleges);
             View::share('selectedcollegeid', $institution->id);
             return View::make('member.addmaincampus')->with('global', 'Success!! College Details saved. Enter Main Campus Details');
         }
         return Redirect::route('newcollege-get')->withInput()->with('global', 'Sorry!! College details were not posted, please retry.');
     }
 }