/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { // use the Find class to get the school object with id. // get school object $schoolobj = School::find($id); // call view passing school object return view('students.studentshome', ['schoolobj' => $schoolobj]); }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function classroom() { foreach (Auth::user()->schools()->lists('school_id')->toArray() as $k => $v) { $value = $v; } $schools = School::find($value); $countUser = $schools->users->count(); return view('principal/classroom', compact('countUser')); }
/** * Store a newly created resource in storage. * * @param CreateStaffRequest $request * * @return \Illuminate\Http\Response */ public function store(CreateStaffRequest $request) { $staff = User::create(['name' => ucwords($request->name), 'bday' => $request->bday, 'gender' => $request->gender, 'email' => $request->email, 'password' => bcrypt($request->password)]); $address = Address::create(['contact11' => $request->contact11]); $staff->addresses()->save($address); foreach (Auth::user()->schools()->lists('school_id')->toArray() as $k => $v) { $value = $v; } $school = School::find($value); $staff->schools()->attach($school); return redirect('principal/create#staff-tab')->withInput(); }
/** * Store a newly created resource in storage. * * @param CreateStudentRequest $request * @return \Illuminate\Http\Response */ public function store(CreateStudentRequest $request) { $student = Student::create(['student' => ucwords($request->student), 'bday' => $request->bday, 'gender' => $request->gender, 'email' => $request->email]); $address = Address::create(['contact11' => $request->contact11]); $student->addresses()->save($address); foreach (Auth::user()->schools()->lists('school_id')->toArray() as $k => $v) { $value = $v; } $school = School::find($value); $grade = Grade::find($request->grade_id); $student->schools()->attach($school); $student->grades()->attach($grade); return redirect('principal/create#student-tab')->withInput(); }
/** * Post from Step 1: School / Organization */ public function post(Request $request) { if ($school = School::find($request->input('school'))) { // update school if advisor already in session if ($advisor = Session::get('advisor')) { $advisor->school_id = $school->id; $advisor->save(); } Session::set('school', $school); return redirect('/event/' . Session::get('event')->slug . '/step/2'); } else { return redirect('/event/' . Session::get('event')->slug . '/start'); } }
public function editSchool($id, Request $request) { $school = School::find($id); $school->bus = $request->input('bus'); $school->save(); if (Input::hasFile('images')) { $files = Input::file('images'); foreach ($files as $file) { $destinationPath = 'uploads'; $filename = $file->getClientOriginalName(); $new_name = uniqid() . "." . File::extension($filename); $upload_success = $file->move(public_path() . "/" . $destinationPath, $new_name); $uploaded_files[] = $destinationPath . "/" . $new_name; } foreach ($uploaded_files as $file) { $photo = new Photo(); $photo->school_id = $school->id; $photo->location = $file; $photo->save(); } } return redirect(url('admin/school/' . $school->id))->with('success', 'Izmena je sacuvana'); }
public function storeCMPost($row, $cm_id) { $content = ucfirst($row['first_name']) . ' ' . ucfirst($row['last_name']) . ' @ ' . \App\School::find($row['school_id'])->name; $img_url = $row['image_url']; // post save $post = $this->model->create(array('user_id' => $cm_id, 'content' => $content)); $post->postGroups()->attach(\App\User::find($cm_id)->postGroups()->first()->id); // photo save $types = array('_s.', '_m.', '_l.'); $sizes = array(100, 300, 600); $original_file_name = $img_url; $file_ext = 'jpg'; $target_path = base_path() . '/public/imgs/'; $hashSeed = "post" . $post->id . $original_file_name; while (1) { $file_name = \Func::getHashedValue($hashSeed); if (!\File::exists($target_path . \Func::getImgPath($file_name))) { break; } $hashSeed .= rand(); } $target_path .= \Func::getImgPath($file_name) . '/'; if (!\File::exists($target_path)) { \File::makeDirectory($target_path, 0775, true); } foreach ($types as $key => $type) { $new_name = $file_name . $type . $file_ext; $img = \Image::make($img_url); $img->resize($sizes[$key], null, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); })->save($target_path . $new_name); $img->destroy(); } $this->photo->create(array('post_id' => $post->id, 'sequence' => 1, 'img_path' => $file_name . '.' . $file_ext)); return $post->id; }
public function pay() { $amount = Input::get('amount'); $school_id = Input::get('school_id'); $school = School::find($school_id); $new_amount = $school->amount_gathered + $amount; $required = $school->amount_required; if ($required > $new_amount) { $school->amount_gathered = $new_amount; } else { $school->amount_gathered = $required; } $school->save(); $actual_link = "http://{$_SERVER['HTTP_HOST']}"; return Redirect::away($actual_link . "/authentication/secure/dashboard/payment-api?amount=" . $amount); }
public function show($id) { return view('school.detail', ['school' => School::find($id)]); }
public function discount_policies(Request $request) { // dd($request); if (isset($request->parent_discount)) { $parent_discount = 1; } else { $parent_discount = 0; } if (isset($request->staff_discount)) { $staff_discount = 1; } else { $staff_discount = 0; } $school = School::find(1); $school->parent_discount = $parent_discount; $school->staff_discount = $staff_discount; $school->save(); return redirect()->back(); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); $school = new \App\School(); $school->name = "Royal College"; $school->city = "Colombo 07"; $school->district = "Colombo"; $school->in_quota = 200; $school->comes_in = true; $school->goes_out = false; $school->cutoff_mark = 175; $school->save(); $school = new \App\School(); $school->name = "Ananda College"; $school->city = "Colombo 10"; $school->district = "Colombo"; $school->in_quota = 150; $school->comes_in = true; $school->goes_out = false; $school->cutoff_mark = 170; $school->save(); $school = new \App\School(); $school->name = "Maliyadeva College"; $school->city = "Kurunegala"; $school->district = "Kurunegala"; $school->in_quota = 100; $school->comes_in = true; $school->goes_out = true; $school->cutoff_mark = 168; $school->save(); $school = new \App\School(); $school->name = "Dharmaraja College"; $school->city = "Kandy"; $school->district = "Kandy"; $school->in_quota = 150; $school->comes_in = true; $school->goes_out = false; $school->cutoff_mark = 172; $school->save(); $school = new \App\School(); $school->name = "Nalanda College"; $school->city = "Colombo 10"; $school->district = "Colombo"; $school->in_quota = 100; $school->comes_in = true; $school->goes_out = false; $school->cutoff_mark = 168; $school->save(); $school = new \App\School(); $school->name = "Mahanama College"; $school->city = "Colombo 03"; $school->district = "Colombo"; $school->in_quota = 50; $school->comes_in = true; $school->goes_out = true; $school->cutoff_mark = 160; $school->save(); $school = new \App\School(); $school->name = "Bandaranayake College"; $school->city = "Gampaha"; $school->district = "Gampaha"; $school->in_quota = 50; $school->comes_in = true; $school->goes_out = true; $school->cutoff_mark = 160; $school->save(); $school = new \App\School(); $school->name = "Horagasmulla Primary School"; $school->city = "Divulapitiya"; $school->district = "Gampaha"; $school->in_quota = 0; $school->comes_in = false; $school->goes_out = true; $school->cutoff_mark = 0; $school->save(); $school = new \App\School(); $school->name = "Balagalla Primary School"; $school->city = "Divulapitiya"; $school->district = "Gampaha"; $school->in_quota = 0; $school->comes_in = false; $school->goes_out = true; $school->cutoff_mark = 0; $school->save(); $school = new \App\School(); $school->name = "Hunumulla Central College"; $school->city = "Hunumulla"; $school->district = "Gampaha"; $school->in_quota = 20; $school->comes_in = true; $school->goes_out = true; $school->cutoff_mark = 136; $school->save(); $names = array('Nipun Perera', 'Imesha Sudasingha', 'Madhawa Vidanapathirana', 'Jayan Chathuranga', 'Pasindu Kanchana', 'Dulaj Atapattu'); for ($i = 0; $i < 20; $i++) { $student = new \App\Student(); $student->name = $names[rand(0, count($names) - 1)]; $student->examination_no = rand(1000000, 9999999); $student->results = rand(100, 200); $student->password = \Illuminate\Support\Facades\Hash::make("1234"); $student->school_id = rand(1, 10); $student->save(); $studentexam = new \App\ExamResultsRest(); $studentexam->name = $student->name; $studentexam->examination_number = $student->examination_no; $studentexam->dob = "1993-05-01"; $studentexam->district = "Colombo"; $studentexam->marks = rand(50, 200); $studentexam->school = School::find($student->school_id)->name; $studentexam->save(); } Model::reguard(); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function bill_class($fee_schedule_code) { // dd($fee_schedule_code); $table = 'fee_sch_' . session()->get('current_session') . '_' . session()->get('current_term'); $fee_schedule = DB::table($table)->where('fee_schedule_code', $fee_schedule_code)->first(); $amount = DB::table($table)->where('fee_schedule_code', $fee_schedule_code)->sum('amount'); $students = Student::where('class_id', $fee_schedule->class_id)->get(); $school = School::find(1); //get all studenta ids who are eligible for the parent discount if ($school->parent_discount == 1) { $children_number = DiscountPolicy::find(1)->children_number; if ($children_number == null) { session()->flash('flash_message', 'Please, set the parent discount values. Go to Billing-> Discount Policies.'); return redirect()->back(); } $parent_discount_eligible = Helper::getParentDiscountEligibles(); sort($parent_discount_eligible); } // dd($parent_discount_eligible); foreach ($students as $student) { $discount = 0; //get parent discount if ($school->parent_discount == 1) { if (in_array($student->id, $parent_discount_eligible)) { $discount = Helper::calculateParentDiscount($student->id, $fee_schedule_code); // dd($discount); } } //calculate total amount due to be paid $total = $amount - $discount; try { \DB::table('invoices_' . \Session::get('current_session') . '_' . \Session::get('current_term'))->insert(['student_id' => $student->id, 'fee_schedule_code' => $fee_schedule_code, 'invoice_number' => str_replace('-', '', $fee_schedule_code) . str_pad($student->id, 3, '0', STR_PAD_LEFT), 'amount' => $amount, 'discount' => $discount, 'balance' => Helper::getStudentCurrentBalance($student->id), 'total' => $total]); } catch (\Illuminate\Database\QueryException $e) { $errorCode = $e->errorInfo[1]; if ($errorCode == 1062) { session()->flash('flash_message', 'Hey, these guys have been invoiced'); return \Redirect::back(); } } } //change the status of the fee schedule after billing class DB::table($table)->where('fee_schedule_code', $fee_schedule_code)->update(['status_id' => 8]); return redirect()->to('billing/invoices'); }
public function change_logo(Requests\ChangePhotoRequest $request) { $extension = $request->avatar_file->getClientOriginalExtension(); Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($request->avatar_file)); $school = School::find($request->school); //$school->mime = $file->getClientMimeType(); //$entry->original_filename = $file->getClientOriginalName(); $school->logo = $file->getFilename() . '.' . $extension; $school->save(); return \Redirect::route('school')->with('message', 'Logo successfuly Changed!'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $school = School::find($id)->delete(); return redirect('admin/school'); }
public function studentsFuturePerformance() { $user = Auth::User(); // find all sections which are teached by the teacher $teachingSections = TeachingSection::where('users_id', '=', $user->id)->get(); $allStudentsAllSections = array(); $i = 0; foreach ($teachingSections as $teachingSection) { $allStudentIdsEachSection = User::getStudentBySection($teachingSection->sections_id); $allStudentsEachSection = DB::table('users')->whereIn('id', $allStudentIdsEachSection)->get(); $allStudentsAllSections[$i]['students'] = $allStudentsEachSection; $section = Section::find($teachingSection->sections_id); $school = School::find($section->schools_id); $allStudentsAllSections[$i]['sectionGrade'] = $section->grade; $allStudentsAllSections[$i]['sectionOrder'] = $section->order; $allStudentsAllSections[$i]['schoolName'] = $school->name; $i++; } // dd($allStudentsAllSections); return view('forecast.studentsFuturePerformance', compact('user', 'allStudentsAllSections')); }
public function report_sheet($student_id, $class_id) { $data['title'] = 'Report Sheet'; $data['results_menu'] = 1; $data['school'] = School::find(1)->first(); $data['offered_subjects'] = \App\Helpers\Helper::get_offered_subjects($class_id, $student_id); $data['class'] = studentClass::find($class_id); $data['student'] = Student::find($student_id); $data['students'] = Student::where(['class_id' => $class_id])->get(); $data['admission_number'] = str_pad(str_replace('-', '/', \Session::get('current_session')) . '/' . $student_id, 4, '0', STR_PAD_LEFT); $positions_table = 'class_positions_' . \Session::get('current_session') . '_' . \Session::get('current_term'); $data['student_position'] = \DB::table($positions_table)->where(['class_id' => $class_id, 'student_id' => $student_id])->first(); return view('academics.results.report_sheet', $data); }
public static function getSchoolBySection($section) { // $sectionId = User::find($user->id)->teachingSection()->first()->value('sections_id'); $school = School::find($section->schools_id); return $school; }