/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //Validation
     $rules = array('name' => 'required|unique:test_categories,name');
     $validator = Validator::make(Input::all(), $rules);
     //process
     if ($validator->fails()) {
         $url = Session::get('SOURCE_URL');
         return Redirect::to($url)->withErrors($validator);
     } else {
         //store
         $testcategory = new TestCategory();
         $testcategory->name = Input::get('name');
         $testcategory->description = Input::get('description');
         try {
             $testcategory->save();
             $url = Session::get('SOURCE_URL');
             return Redirect::to($url)->with('message', trans('messages.success-creating-test-category'))->with('activetestcategory', $testcategory->id);
         } catch (QueryException $e) {
             Log::error($e);
         }
     }
 }