/**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $data['title'] = 'Create Class';
     $data['classes_menu'] = 1;
     $data['staffs'] = Staff::select(\DB::raw('concat (fname," ",lname) as full_name, id'))->where('staff_type_id', 1)->lists('full_name', 'id')->prepend('Please Select');
     $data['subjects'] = Subject::lists('subject', 'id')->prepend('Please Select');
     $data['classes'] = studentClass::lists('name', 'id')->prepend('Please Select');
     return view('settings.class.create', $data);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function class_invoices(Request $request)
 {
     // dd($request->all());
     //ensure a class as selected
     if (0 == $request->class_id) {
         session()->flash('flash_message', 'Select Class');
         return \Redirect::back()->withInput();
     }
     //ensure a session as selected
     if (0 == $request->session) {
         session()->flash('flash_message', 'Select Session');
         return \Redirect::back()->withInput();
     }
     //ensure a term as selected
     if (0 == $request->term_id) {
         session()->flash('flash_message', 'Select Term');
         return \Redirect::back()->withInput();
     }
     //ensure at least on element was selected
     $data['title'] = 'Invoices';
     $data['invoice_menu'] = 1;
     // {class_id}{session}{term_id}
     $fee_schedule_code = strval($request->class_id) . $request->session . strval($request->term_id);
     $data['session'] = $request->session;
     $data['class'] = StudentClass::findOrFail($request->class_id)->name;
     $data['term'] = $request->term_id;
     //get invoices
     $data['invoices'] = \DB::table('invoices_' . \Session::get('current_session') . '_' . \Session::get('current_term'))->where('fee_schedule_code', $fee_schedule_code)->get();
     // dd($data['invoices']);
     //create array to hole school session starting 10 yrs from current date
     $sessions = ['Select Session'];
     for ($i = intval(date('Y')) - 10; $i < intval(date('Y')) + 15; $i++) {
         $session = $i . '-' . ($i + 1);
         $sessions[$session] = $session;
     }
     $data['sessions'] = $sessions;
     $data['terms'] = ['Select Term', 1, 2, 3];
     $data['classes'] = studentClass::lists('name', 'id')->prepend('Select Class');
     $data['fee_elements'] = FeeElement::where('status_id', 1)->get();
     return view('billing.invoices.class_invoices', $data);
 }