/**
  * This function takes care of the post method in add event category page.
  *
  * @param string        POST Data
  *
  * @return if validation error - same page | if db error event category page with error message  | no errors event categories page with success message
  */
 public function AddEventCategoriesPost()
 {
     //get form inputs
     $input = Request::all();
     //create validation input array
     $rules = array('ename' => 'regex:/(^[A-Za-z ]+$)+/');
     //use laravel validation class
     $validation = Validator::make($input, $rules);
     //redirect if validation fails
     if ($validation->fails()) {
         return redirect('dashboard/events/categories/add')->withErrors($validation)->withInput();
     }
     //get inputs to variables
     $iName = $input['ename'];
     $iTasks = array();
     $iSlug = str_replace(" ", "-", $iName);
     $iSlug = strtolower($iSlug);
     //if image upload is errorsome use default image
     if ($_FILES["img"]["error"] != 0) {
         $filefull = 'na.png';
     } else {
         $fileext = Request::file('img')->getClientOriginalExtension();
         //if image is not png, redirect with error message
         if ($fileext != 'png') {
             return redirect('dashboard/events/categories')->with('message', 'Record Update Failed');
         }
         //modify image name
         $filename = Request::file('img')->getClientOriginalName();
         $filefull = $iName . '.' . $fileext;
         $filefull = str_replace(' ', '_', $filefull);
         //upload the selected image to the path
         Request::file('img')->move(base_path() . '/public/images/event-icons', $filefull);
     }
     try {
         //add the inputs to database
         Event_Types::insert([['EventName' => $iName, 'Icon' => $filefull, 'EventSlug' => $iSlug]]);
         foreach ($input['eservices'] as $x) {
             $iTasks[] = $x;
             Event_Services::insert([['EventName' => $iName, 'Service' => $x]]);
         }
         return redirect('dashboard/events/categories')->with('message', 'Record Added Successfully');
     } catch (\Illuminate\Database\QueryException $e) {
         return redirect('dashboard/events/categories')->with('message', 'Record Update Failed');
     }
 }