public function studentPerSchoolFilter($id) { $school = School::find($id); $educations = Education::where('project_id', '=', Auth::user()->curr_project_id)->where('school_id', '=', $id)->get(); $menu = 'report'; return View::make('reports.studentperschool', compact('educations', 'school', 'menu')); }
protected static function boot() { parent::boot(); static::creating(function ($model) { $data = array('municipality_id' => $model->municipality_id, 'name' => $model->name); $rules = array('municipality_id' => 'required|integer|min:1|max:300000', 'name' => 'required|min:3|max:50'); $validator = Validator::make($data, $rules); if ($validator->fails()) { throw new ValidationException(null, null, null, $validator->messages()); } else { return $model->validate(); } }); static::updating(function ($model) { $data = array('municipality_id' => $model->municipality_id, 'name' => $model->name); $rules = array('municipality_id' => 'required|integer|min:1|max:300000', 'name' => 'required|min:3|max:50'); $validator = Validator::make($data, $rules); if ($validator->fails()) { throw new ValidationException(null, null, null, $validator->messages()); } else { return true; } }); static::deleting(function ($model) { $schools = School::where('city_id', '=', $model->id)->get(); foreach ($schools as $school) { $school = School::find($school->id)->delete(); } return true; }); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $menu = Menu::where('tipe', Sentry::getUser()->last_name)->get(); $school = School::where('user_id', Sentry::getUser()->id)->first(); $profile = School::find($school->id); return View::make('profile.index', compact('profile'))->withTitle('Profile')->with('menu', $menu); }
function isexist($zipcode) { $Model_B = new School(); $valid = $Model_B->find('count', array('conditions' => array('School.school_code' => $zipcode))); if ($valid == 1) { return true; } else { return false; } }
/** * Display a listing of the resource. * * @return Response */ public function edit($id) { $school = School::find($id); if (is_null($school)) { return Redirect::route('admin.schools.index')->withErrors(array('mainError' => 'Училището не е намерено.')); } else { $school_name = Type::find($school->type_id)->name . ' "' . $school->name . '"'; $comments = VisitorComments::where("school_id", "=", $id)->get(); return View::make('admin.school.comments')->with('school_name', $school_name)->with('comments', $comments); } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $school = School::find($id); if (is_null($school)) { return Redirect::route('schools.index')->withErrors(array('mainError' => 'Училището не е намерено.')); } else { if ($school->status == false) { return Redirect::route('schools.index')->withErrors(array('mainError' => 'Училището не е намерено.')); } return View::make('view')->with('school', $school); } }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $school = School::find($id); if (is_null($school)) { return Redirect::route('admin.galleries.index')->withErrors(array('mainError' => 'Галерията не е намерена.')); } else { if ($school->canUserEdit() == false) { return Redirect::route('admin.schools.index')->withErrors(array('mainError' => 'Нямате право да редактирате учебното заведение.')); } $photos_data = Gallery::where('school_id', '=', $id)->get(); return View::make('admin.gallery.edit')->with('photos', $photos_data)->with('gallery_id', $id); } }
public function deleteAction() { $input = Input::all(); $id = $input["id"]; $schoolToUser = DB::table('schooluser')->where('school', $id); $schoolToClass = DB::table('schoolclass')->where('school', $id); $status = false; if ($schoolToUser->count() < 1 || $schoolToClass->count() < 1) { $school = School::find($id); $school->deleted_at = new DateTime(date('Y-m-d H:i:s')); $school->save(); $status = true; $message = ""; } else { $message = "Sorry. You cannot delete this school. \n To delete this class, you should remove the students from class and then remove this class from school first."; } $responses = array('idx' => $id, 'message' => $message, 'status' => $status); return Response::json($responses); }
$req_body = json_decode($app->request->getBody()); // Check if all fields are present if ($req_body->gender == NULL || $req_body->nickname == NULL || $req_body->password1 == NULL || $req_body->password2 == NULL || $req_body->school == NULL) { $app->halt(400, '{"message": "er is iets fout gegeaan"}'); } // Check if username exists if (User::where('nickname', 'like', $req_body->nickname)->count()) { $app->halt(400, 'nickname_exists'); } try { $user = new User(); $user->nickname = $req_body->nickname; $user->gender = $req_body->gender; $user->password = sha1($req_body->password1); $user->educationLevel()->associate(EducationLevel::find((int) $req_body->schoolAdvice)); $user->school()->associate(School::find((int) $req_body->school)); $user->save(); // Create token $token = new Token(); $token->generateToken(); $token->user()->associate($user); $token->save(); } catch (Exception $e) { $app->halt(500, 'something_went_wrong'); } echo $token->toJson(); }); $app->get('/user', function () use($app) { $app->response()->header('Content-Type', 'application/json'); $token_key = $app->request->headers->get('Authorization'); try {
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // $school = School::find($id); $school->delete(); }
/** * Show the form for editing the specified school. * * @param int $id * @return Response */ public function edit($id) { $school = School::find(Crypt::decrypt($id)); return View::make('schools.edit', compact('school')); }
/** * Deactivate school to end user. * * @param int $id * @return Response */ public function deactivate($id) { $school = School::find($id); if (!is_null($school)) { $school->status = false; if ($school->save()) { return Redirect::route('admin.schools.index')->withErrors(array('mainSuccess' => 'Учебното заведение е успешно скрит от сайта.')); } else { return Redirect::route('admin.schools.index')->withErrors(array('mainError' => 'Грешка с базата данни.')); } } else { return Redirect::route('admin.schools.index')->withErrors(array('mainError' => 'Учебното заведение не е намерено.')); } }
public function generatedpasswords() { $school = School::find(intval(Input::get('school'))); $text = ''; foreach (User::where('school_id', intval(Input::get('school')))->where('paid', 1)->get() as $user) { $password = str_random(6); $hash = Hash::make($password); $user->password = $hash; $user->save(); $text .= '<tr><td>' . $user->name1 . '</td><td>' . $user->name2 . '</td><td>' . $user->roll . '</td><td> ' . $password . '</td></tr>'; } return View::make('admin.generatedpass')->with('body', $text)->with('school', $school); }
public function admitdownload($school) { try { $school = Crypt::decrypt($school); $school = School::find($school); } catch (Exception $e) { return View::make('layouts.error'); } return Response::download('admit-cards/schools/' . $school->id . '.pdf', $school->name . '.pdf', array('Content-type:application/pdf', 'filename')); }
public function test3() { $user = User::find(1); $password = str_random(6); $school = School::find($user->school_id); $city = City::find($user->city_id); $state = State::find($city->state_id); $name = "Aneesh Dash"; $to = "Aneesh Dash<*****@*****.**>"; $subject = "Technothlon Registration Details"; $message = "\n <html lang='en'>\n <head>\n <meta charset='UTF-8'>\n <title>Technothlon Registration Details</title>\n </head>\n <body>\n <div style='display: table; margin: 0 auto'>\n <div style='text-align: center'>\n <img src='technothlon.png'; width='300px'>\n </div><br><br>\n <div style='display: inline-block'>\n Dear" . $name . ",<br>\n You have successfully registered for Technothlon 2015 with the following details: <br><br>\n <div id='school'>\n <div style='display: inline-block'>\n <div>\n School Name:\n </div>\n <div>\n School Address:\n </div>\n <div>\n City:\n </div>\n <div>\n State\n </div>\n </div>\n <div style='display: inline-block; margin-left: 10px'>\n <div>\n " . $school->name . "\n </div>\n <div>\n " . $school->address . "\n </div>\n <div>\n " . $city->name . "\n </div>\n <div>\n " . $state->name . "\n </div>\n </div>\n </div>\n <div><br>\n <div style='display: inline-block'>\n Squad: {{ {$user->squad} }}\n </div>\n <div style='display: inline-block; margin-left: 20px'>\n Medium: {{ {$user->language} }}\n </div>\n </div><br>\n <div id='details'>\n <div style='display: inline-block'>\n <div style='display: inline-block'>\n <div>\n Name:\n </div>\n <div>\n Email:\n </div>\n <div>\n Contact:\n </div>\n </div>\n <div style='display: inline-block; margin-left: 10px'>\n <div>\n " . $user->name1 . "\n </div>\n <div>\n " . $user->email1 . "\n </div>\n <div>\n +91" . $user->contact1 . "\n </div>\n </div>\n </div>\n <div style='display: inline-block; margin-left: 20px'>\n <div style='display: inline-block'>\n <div>\n Name:\n </div>\n <div>\n Email:\n </div>\n <div>\n Contact:\n </div>\n </div>\n <div style='display: inline-block; margin-left: 10px'>\n <div>\n " . $user->name2 . "\n </div>\n <div>\n " . $user->email2 . "\n </div>\n <div>\n +91" . $user->contact2 . "\n </div>\n </div>\n </div>\n </div>\n </div><br><br><br><br>\n <div id='roll'>\n Given below is your roll number and password which will be required for accessing technopedia<br> and other features of Technothlon.<br><br>\n <div style='display: inline-block;'>\n <div>Roll Number:</div>\n <div>Password:</div>\n </div>\n <div style='display: inline-block;'>\n <div>" . $user->roll . "</div>\n <div>" . $password . "</div>\n </div><br><br>\n <div id='details'>\n <ul>\n <li>The exam is on 19th July, 2015.</li>\n <li>Technopedia starts from the 15th of every month and ends on the 10th of next month.</li>\n <li>The first Technopedia starts from January</li>\n <li>In case of any discrepancy, <a href='http://technothlon.techniche.org/contact' target='_blank'>Contact Us</a>. </li>\n </ul>\n </div>\n </div>\n</div>\n</body>\n</html>\n "; // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; // More headers $headers .= 'From: Technothlon<*****@*****.**>' . "\r\n"; mail($to, $subject, $message, $headers); }
if ($last_card == null) { $last_id[$sprint->school . '-' . $sprint->id] = ''; } else { $last_id[$sprint->school . '-' . $sprint->id] = $last_card->card; } } return View::make("student.sprints")->with("title", "Sprint")->with("sprints", $sprints)->with("course_name", $course_name)->with("masteredCards", $masteredCards)->with("play_status", $play_status)->with("status", $status)->with("last_id", $last_id)->with("studyroom", false)->with("user", $user); })); Route::get("course/student_sprints/{course}", array("as" => "student/sprintsBycourse", function ($course) { $user = Auth::user(); $sprints = DB::table('sprints')->where('course', $course)->where('deleted_at', NULL)->get(); return View::make("student.sprints")->with("title", "Sprint")->with("sprints", $sprints)->with("user", $user); })); Route::get("student_school/{school}", array("as" => "students/school", function ($school) { $user = Auth::user(); $schoolInfo = School::find($school); $schools = DB::table('school')->leftJoin('schooluser', 'school.id', '=', 'schooluser.school')->where('schooluser.user', $user->id)->where('school.deleted_at', NULL)->orderBy('schooluser.school', 'asc')->get(); $classes = DB::table('classes')->join('schoolclass', 'classes.id', '=', 'schoolclass.class')->where('schoolclass.school', $school)->where('classes.deleted_at', NULL)->orderBy('classes.name', 'asc'); return View::make("student.schools")->with("title", "My School")->with("schoolInfo", $schoolInfo)->with("classes", $classes)->with("schools", $schools)->with("user", $user); })); //Route to user account Route::get("account", array("as" => "student/account", function () { $user = Auth::user(); return View::make("student.account")->with("title", "Account Information")->with("sub_title", "")->with("studyroom", false)->with("user", $user); })); /* Card START*/ Route::post("student_card", array("as" => "student/card", function () { $user = Auth::user(); $id = Input::get('id'); $cards = DB::table('cards')->where('sprint', $id)->get(); $subcards = array();
public function getSchoolNameAttribute() { return School::find($this['school_id'])->name; }
$data['school']->delete(); } $app->render('schools/delete.html', $data); })->via('GET', 'POST')->name('schools_delete'); $app->map('/new', function () use($app, $data) { if ($app->request->isPost()) { $school = new School(); $school->name = $app->request->post('name'); $school->save(); $data['new_school'] = $school; } $app->render('schools/new.html', $data); })->via('GET', 'POST')->name('schools_new'); $app->map('/edit/:id', function ($id) use($app, $data) { $data['request_method'] = $app->request->getMethod(); $school = School::find($id); if ($app->request->isGet()) { $data['school'] = $school->toArray(); } else { if ($app->request->isPost()) { $school->name = $app->request->post('name'); $school->save(); $data['new_school'] = $school->toArray(); } } $app->render('schools/edit.html', $data); })->via('GET', 'POST')->name('schools_edit'); }); $app->map('/login', function () use($app) { $data = array(); if ($app->request->isPost()) {
public function getById($id) { return School::find($id); }