/**
  * 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.");
         }
     }
 }
 public function printlist($class, $section, $shift, $session, $subject, $date)
 {
     if ($class != "" && $section != "" && $shift != "" && $subject != "" && $date) {
         $className = ClassModel::select('name')->where('code', $class)->first();
         $subjectName = Subject::select('name')->where('code', $subject)->first();
         $attendance = DB::table('Attendance')->join('Student', 'Attendance.regiNo', '=', 'Student.regiNo')->select('Attendance.id', 'Attendance.regiNo', 'Student.rollNo', 'Student.firstName', 'Student.middleName', 'Student.lastName', 'Attendance.status')->where('Attendance.class', '=', $class)->where('Attendance.section', '=', $section)->Where('Attendance.shift', '=', $shift)->where('Attendance.session', '=', trim($session))->where('Attendance.subject', '=', $subject)->where('Attendance.date', '=', $this->parseAppDate($date))->get();
         $input = array($className->name, $section, $shift, $session, $subjectName->name, $date);
         $fileName = $className->name . '-' . $section . '-' . $shift . '-' . $section . '-' . $subjectName->name . '-' . $date;
         Excel::create($fileName, function ($excel) use($input, $attendance) {
             $excel->sheet('New sheet', function ($sheet) use($input, $attendance) {
                 $sheet->loadView('app.attendanceExcel', compact('attendance', 'input'));
             });
         })->download('xlsx');
         // return "true";
     } else {
         return "Please fill up form correctly!";
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $classes = ClassModel::select('name', 'code')->get();
     return View::Make('app.studentCreate', compact('classes'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show()
 {
     $formdata = new formfoo();
     $formdata->class = "";
     $formdata->section = "";
     $formdata->shift = "";
     $formdata->session = "";
     $formdata->subject = "";
     $formdata->exam = "";
     $classes = ClassModel::select('code', 'name')->orderby('code', 'asc')->get();
     //$subjects = Subject::lists('name','code');
     $marks = array();
     //$formdata["class"]="";
     return View::Make('app.markList', compact('classes', 'marks', 'formdata'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $classes = ClassModel::select('code', 'name')->orderby('code', 'asc')->get();
     return View::Make('app.subjectCreate', compact('classes'));
 }
 public function search()
 {
     $formdata = new formfoo();
     $formdata->exam = "";
     $classes = ClassModel::select('code', 'name')->orderby('code', 'asc')->get();
     return View::Make('app.resultsearch', compact('formdata', 'classes'));
 }