/**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $rules = ['name' => 'required', 'code' => 'required|max:20', 'description' => 'required'];
     $validator = \Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('/class/create')->withErrors($validator);
     } else {
         $clcode = 'cl' . Input::get('code');
         $cexists = ClassModel::select('*')->where('code', '=', $clcode)->get();
         if (count($cexists) > 0) {
             $errorMessages = new Illuminate\Support\MessageBag();
             $errorMessages->add('deplicate', 'Class all ready exists!!');
             return Redirect::to('/class/create')->withErrors($errorMessages);
         } else {
             $class = new ClassModel();
             $class->name = Input::get('name');
             $class->code = $clcode;
             $class->description = Input::get('description');
             $class->save();
             return Redirect::to('/class/create')->with("success", "Class Created Succesfully.");
         }
     }
 }