/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $student = Student::find($id); if ($student == NULL) { throw new Exception('Invalid Student ID'); } $student->year = (int) substr($student->year, 2, 4); $student_category = StudentCategories::find($student->category); $student->category = $student_category->category; $student_branch = Branch::find($student->branch); $student->branch = $student_branch->branch; if ($student->rejected == 1) { unset($student->approved); unset($student->books_issued); $student->rejected = (bool) $student->rejected; return $student; } if ($student->approved == 0) { unset($student->rejected); unset($student->books_issued); $student->approved = (bool) $student->approved; return $student; } unset($student->rejected); unset($student->approved); $student_issued_books = Logs::select('book_issue_id', 'issued_at')->where('student_id', '=', $id)->orderBy('time_stamp', 'desc')->take($student->books_issued)->get(); foreach ($student_issued_books as $issued_book) { $issue = Issue::find($issued_book->book_issue_id); $book = Books::find($issue->book_id); $issued_book->name = $book->title; $issued_book->issued_at = date('d-M', $issued_book->issued_at); } $student->issued_books = $student_issued_books; return $student; }
/** * Run the database seeds. * * @return void */ public function run() { Eloquent::unguard(); DB::table('propel_fellow_wingman')->delete(); DB::table('propel_student_wingman')->delete(); Subject::truncate(); DB::table('propel_city_subject')->delete(); CalendarEvent::truncate(); CancelledCalendarEvent::truncate(); WingmanModule::truncate(); WingmanTime::truncate(); VolunteerTime::truncate(); WingmanJournal::truncate(); $fellow = Fellow::find(1); $wingman1 = Wingman::find(2); $wingman2 = Wingman::find(3); $fellow->wingman()->attach($wingman1); $fellow->wingman()->attach($wingman2); $student1 = Student::find(3); $student2 = Student::find(4); $wingman1->student()->attach($student1); $wingman1->student()->attach($student2); $cEvent1 = new CalendarEvent(); $cEvent1->type = 'volunteer_time'; $cEvent1->student()->associate($student1); $cEvent1->status = 'created'; $cEvent1->save(); $vTime1 = new VolunteerTime(); $vTime1->calendarEvent()->associate($cEvent1); $volunteer1 = Volunteer::find(4); $vTime1->volunteer()->associate($volunteer1); $subject1 = new Subject(); $subject1->name = "English"; $subject1->save(); $vTime1->subject()->associate($subject1); $vTime1->save(); $cEvent2 = new CalendarEvent(); $cEvent2->type = 'wingman_time'; $cEvent2->student()->associate($student1); $cEvent2->status = 'created'; $cEvent2->save(); $wTime1 = new WingmanTime(); $wTime1->calendarEvent()->associate($cEvent2); $wTime1->wingman()->associate($wingman1); $wModule1 = new WingmanModule(); $wModule1->name = "Programming"; $wModule1->save(); $wTime1->wingmanModule()->associate($wModule1); $wTime1->save(); $city1 = City::find(1); $subject1->city()->attach($city1); $wJournal1 = new WingmanJournal(); $wJournal1->type = 'formal'; $wJournal1->title = "Day at Navy Camp"; $wJournal1->mom = "It was awesome"; $wJournal1->student()->associate($student1); $wJournal1->wingman()->associate($wingman1); $wJournal1->save(); }
public function childWingmanModules($student_id) { $student = Student::find($student_id); $tables = DB::table('propel_calendarEvents as A')->join('propel_wingmanTimes as B', 'B.calendar_event_id', '=', 'A.id')->join('propel_wingmanModules as C', 'C.id', '=', 'B.wingman_module_id'); $wingmanModules = $tables->select('A.start_time as time', 'C.name as name', 'C.id')->where('A.status', '=', 'attended')->distinct('B.wingman_id')->where('A.start_time', '<=', date('c'))->orderby('C.id', 'ASC')->where('A.student_id', $student_id)->get(); $wingman = $student->wingman()->get(); //return $wingmanModules; return View::make('profile.modules')->with('wingmanModules', $wingmanModules)->with('child', $student)->with('wingman', $wingman); }
function test_find() { $name = "Mike"; $enrollment_date = "2015-12-12"; $test_student = new Student($name, $enrollment_date); $test_student->save(); $name2 = "The Same Exact Name"; $enrollment_date2 = "2015-12-12"; $test_student2 = new Student($name2, $enrollment_date2); $test_student2->save(); $result = Student::find($test_student->getId()); $this->assertEquals($test_student, $result); }
function testFind() { $name = "Bob"; $enrollment_date = "2015-01-01"; $test_student = new Student($name, $enrollment_date); $test_student->save(); $name2 = "Kevin"; $enrollment_date2 = "2015-02-01"; $test_student2 = new Student($name, $enrollment_date); $test_student2->save(); $result = Student::find($test_student->getId()); $this->assertEquals($test_student, $result); }
function test_find() { $student_name = "Abe Lincoln"; $enroll_date = "06-15-2015"; $test_student = new Student($student_name, $enroll_date); $test_student->save(); $student_name2 = "George Washington"; $enroll_date2 = "05-30-2015"; $test_student2 = new Student($student_name2, $enroll_date2); $test_student2->save(); $result = Student::find($test_student->getId()); $this->assertEquals($test_student, $result); }
/** * Sync Matters completeds. * * @param int $student_id * @param array $data * @return bool */ public function sync($student_id, array $data = []) { $student = Student::find($student_id); $sync = []; foreach ($data as $value) { $sync[] = $value['id']; } if (is_null($student)) { return false; } $student->matterCompleteds()->sync($sync); return true; }
function test_find() { //Arrange $test_department = new Department("Biology", "346 Stupid Avenue"); $test_department->save(); $name = "Ashlin Aronin"; $enrollment_date = "2015-08-24"; $test_student = new Student($name, $enrollment_date, $test_department->getId()); $test_student->save(); $name2 = "John Nolastname"; $enrollment_date2 = "2015-07-20"; $test_student2 = new Student($name, $enrollment_date, $test_department->getId()); $test_student2->save(); //Act $result = Student::find($test_student2->getId()); //Assert $this->assertEquals($test_student2, $result); }
function testFind() { //arrange $student_name = "Chemistry"; $student_id = 1; $student_number = "2015-12-12"; $test_student = new Student($student_name, $student_number, $student_id); $test_student->save(); $student_name2 = "Underwater Basketweaving"; $student_id2 = 2; $student_number2 = "2015-12-12"; $test_student2 = new Student($student_name2, $student_number2, $student_id2); $test_student2->save(); //act $result = Student::find($test_student->getStudentId()); //assert $this->assertEquals($test_student, $result); }
public function Welcome() { $lastHolText = Setting::where('item', '=', 'lastHolText')->first()->value; $lastHolDate = Setting::where('item', '=', 'lastHolDate')->first()->value; $export[] = array("id" => " ", "title" => $lastHolText, "day" => $lastHolDate, "writer" => " ", "body" => " ", "file" => " ", "image" => " ", "link" => " ", "view" => " "); if (Newsstu::all()->count() > 0) { $newsstu = Newsstu::take(2)->orderBy("id", "desc")->get(); for ($i = 0; $i < count($newsstu); $i++) { $export[] = array("id" => " ", "title" => urlencode(trim($newsstu[$i]->web_main_top_title)), "day" => urlencode(trim($newsstu[$i]->web_main_top_day)), "writer" => urlencode(trim($newsstu[$i]->web_main_where)), "body" => urlencode(base64_encode($newsstu[$i]->web_main_data)), "file" => urlencode(trim($newsstu[$i]->web_main_link)), "image" => urlencode(trim($newsstu[$i]->web_main_file)), "link" => urlencode(trim($newsstu[$i]->web_main_outside_link)), "view" => " "); } } if (Topic::all()->count() > 0) { $topics = Topic::take(2)->orderBy("sn", "desc")->get(); for ($i = 0; $i < count($topics); $i++) { $writer = Student::find($topics[$i]->stu_id); $export[] = array("id" => urlencode($topics[$i]->id), "title" => urlencode(addslashes($topics[$i]->title)), "day" => " ", "writer" => urlencode(addslashes($writer->nick)), "body" => urlencode(base64_encode($topics[$i]->body)), "file" => urlencode(addslashes($topics[$i]->file)), "image" => " ", "link" => " ", "view" => urlencode($topics[$i]->view)); } } return urldecode(json_encode($export)); }
/** * Searches for student */ public function searchAction() { $numberPage = 1; if ($this->request->isPost()) { $query = Criteria::fromInput($this->di, "Student", $_POST); $this->persistent->parameters = $query->getParams(); } else { $numberPage = $this->request->getQuery("page", "int"); } $parameters = $this->persistent->parameters; if (!is_array($parameters)) { $parameters = array(); } $parameters["order"] = "id"; $student = Student::find($parameters); if (count($student) == 0) { $this->flash->notice("The search did not find any student"); return $this->dispatcher->forward(array("controller" => "student", "action" => "index")); } $paginator = new Paginator(array("data" => $student, "limit" => 10, "page" => $numberPage)); $this->view->page = $paginator->getPaginate(); }
public function forumId($id) { if (Topic::where('id', '=', $id)->count() > 0) { $topic = Topic::find($id); $topic->view = $topic->view + 1; $topic->save(); if (Commit::where('topic_id', '=', $id)->count() > 0) { $commit = Commit::where('topic_id', '=', $id)->get(); } else { $commit = array("無留言"); } $writer = Student::find($topic->stu_id); $export[] = array("title" => urlencode(str_replace("\\'", "'", addslashes($topic->title))), "writer" => urlencode(str_replace("\\'", "'", addslashes($writer->nick))), "body" => urlencode(str_replace("\\'", "'", base64_encode($topic->body))), "file" => urlencode(str_replace("\\'", "'", addslashes($topic->file))), "date" => $topic->day, "view" => $topic->view); if ($commit[0] != "無留言") { for ($i = 0; $i < count($commit); $i++) { $export[] = array("title" => "", "writer" => urlencode(str_replace("\\'", "'", addslashes(Student::find($commit[$i]->stu_id)->nick))), "body" => urlencode(str_replace("\\'", "'", base64_encode($commit[$i]->body))), "file" => " ", "date" => $commit[$i]->day); } } } else { $export[] = array("title" => " ", "writer" => " ", "body" => " ", "file" => " ", "day" => " "); } return urldecode(json_encode($export)); }
/** * Show chat home view * * @return View */ public function showView() { $users = array(); $user = UserController::getUser(Auth::user()); if ($user instanceof Teacher) { $sectionCodes = SectionCode::where('teacher_id', new MongoId($user->_id))->where('status', true)->get(); foreach ($sectionCodes as $sectionCode) { foreach ($sectionCode->teamleaders_id as $id) { array_push($users, Student::find($id)); } $users = array_unique($users); } } else { if ($user instanceof Student) { $sectionCodes = SectionCode::whereIn('students_id', array(new MongoId($user->_id)))->where('status', true)->get(); foreach ($sectionCodes as $sectionCode) { foreach ($sectionCode->students_id as $id) { if ($id != Auth::id()) { array_push($users, Student::find($id)); } } $count = SectionCode::whereIn('teamleaders_id', array(Auth::id()))->where('_id', new MongoId($sectionCode->_id))->count(); if ($count > 0) { array_push($users, Teacher::find($sectionCode->teacher_id)); } $users = array_unique($users); } } else { if ($user instanceof University) { return View::make('error.403'); } } } $ip = App::isLocal() ? '127.0.0.1' : '104.131.3.39'; return View::make('chat.home')->with(array('contacts' => $users, 'user' => $user, 'ip' => $ip)); }
function test_find() { //Arrange $name = "Jack"; $date_of_enrollment = "2012-02-12"; $name2 = "Billy"; $date_of_enrollment2 = "2011-04-14"; $id = 1; $id2 = 2; $test_student = new Student($name, $date_of_enrollment, $id); $test_student->save(); $test_student2 = new Student($name2, $date_of_enrollment2, $id2); $test_student2->save(); //Act $result = Student::find($test_student->getId()); //Assert $this->assertEquals($test_student, $result); }
function testFind() { //Arrange $name = "Elliot Michaels"; $date = "2015-08-03"; $id = 1; $test_student = new Student($name, $date, $id); $test_student->save(); $name2 = "Drake Michaels"; $date2 = "2011-02-02"; $id2 = 2; $test_student2 = new Student($name2, $date2, $id2); $test_student2->save(); //Act $result = Student::find($test_student->getId()); //Assert $this->assertEquals($test_student, $result); }
<th>#</th> <th>{{Lang::get('register_group.subject')}}</th> <th>{{Lang::get('register_group.section_code')}}</th> <th>{{Lang::get('register_group.section')}}</th> <th>{{Lang::get('register_group.student')}}</th> <th>{{Lang::get('register_group.approve')}}</th> <th>{{Lang::get('register_group.deny')}}</th> </tr> </thead> <tbody> @foreach($pending as $index => $item) <?php $section_code = SectionCode::find($item->section_code_id); $subject = Subject::find($section_code->subject_id); $section = $subject->sections()->find($section_code->section_id); $student = Student::find($item->student_id); ?> <tr id="{{$index+1}}"> <td>{{$index+1}}</td> <td>{{$subject->name}}</td> <td>{{$section->code}}</td> <td>{{$section_code->code}}</td> <td>{{$student->name.' '.$student->last_name.' - ('.$student->id_number.')'}}</td> <td style="width:6%"> <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#deleteModal" onclick="approve('{{$item->_id}}', {{$index+1}})"> {{Lang::get('register_group.approve')}} </button> </td> <td style="width:6%"> <button type="button" class="btn btn-danger btn-sm" data-toggle="modal" data-target="#deleteModal" onclick="deny('{{$item->_id}}', {{$index+1}})"> {{Lang::get('register_group.deny')}}
public function store() { // Get StudentID // From student_id or Create New // Create Registration // Create Issue // Create Education // Create Placement // Create Receivables // Reductions // Create Installment try { //DB::beginTransaction(); if (Input::get('student_id') == 0) { // Create New Student $student = new Student(); $student->name = Input::get('name'); $student->sex = Input::get('sex'); $student->birthplace = Input::get('birthplace'); $student->birthdate = date('Y-m-d', strtotime(Input::get('birthdate'))); $student->religion = Input::get('religion'); $student->address = Input::get('address'); $student->contact = Input::get('contact'); $student->email = Input::get('email'); if (Input::get('sex') == 'L') { $student->photo = 'boy.png'; } else { $student->photo = 'girl.png'; } $student->father_name = Input::get('father_name'); $student->father_occupation = Input::get('father_occupation'); $student->father_address = Input::get('father_address'); $student->father_contact = Input::get('father_contact'); $student->father_email = Input::get('father_email'); $student->mother_name = Input::get('mother_name'); $student->mother_occupation = Input::get('mother_occupation'); $student->mother_address = Input::get('mother_address'); $student->mother_contact = Input::get('mother_contact'); $student->mother_email = Input::get('mother_email'); $student->save(); $id = $student->id; } else { $student = Student::find(Input::get('student_id')); $student->name = Input::get('name'); $student->sex = Input::get('sex'); $student->birthplace = Input::get('birthplace'); $student->birthdate = date('Y-m-d', strtotime(Input::get('birthdate'))); $student->religion = Input::get('religion'); $student->address = Input::get('address'); $student->contact = Input::get('contact'); $student->email = Input::get('email'); if (Input::get('sex') == 'L') { $student->photo = 'boy.png'; } else { $student->photo = 'girl.png'; } $student->father_name = Input::get('father_name'); $student->father_occupation = Input::get('father_occupation'); $student->father_address = Input::get('father_address'); $student->father_contact = Input::get('father_contact'); $student->father_email = Input::get('father_email'); $student->mother_name = Input::get('mother_name'); $student->mother_occupation = Input::get('mother_occupation'); $student->mother_address = Input::get('mother_address'); $student->mother_contact = Input::get('mother_contact'); $student->mother_email = Input::get('mother_email'); $student->save(); $id = $student->id; } // Create Registration Data $registration = new Registration(); $registration->project_id = Auth::user()->curr_project_id; $registration->location_id = Auth::user()->location_id; $registration->student_id = $id; $registration->classification_id = Input::get('classification'); $registration->base_id = Input::get('location'); $registration->registration_date = date('Y-m-d', strtotime(Input::get('registration_date'))); $registration->registration_cost = Input::get('fee'); $registration->recommender_type = Input::get('recommender_type'); $registration->recommender_id = Input::get('recommender_id'); $registration->employee_id = Input::get('employee'); $registration->save(); // Create Issue $issue = new Issue(); $issue->project_id = Auth::user()->curr_project_id; $issue->location_id = Auth::user()->location_id; $issue->registration_id = $registration->id; $issue->generation_id = Input::get('generation'); $issue->student_id = $id; $issue->issue = Input::get('issue'); $issue->save(); //Create Education Data if (Input::get('school') != '0') { $education = new Education(); $education->project_id = Auth::user()->curr_project_id; $education->issue_id = $issue->id; $education->school_id = Input::get('school'); $education->generation_id = Input::get('generation'); $education->save(); } // Receivables - Registration Costs $receivable = new Receivable(); $receivable->project_id = Auth::user()->curr_project_id; $receivable->location_id = Auth::user()->location_id; $receivable->issue_id = $issue->id; $receivable->registration_id = $registration->id; $receivable->total = Input::get('total'); $receivable->billable = Input::get('billable'); $receivable->receivable = Input::get('receivables'); $receivable->balance = Input::get('billable'); if (Input::get('payment') == 0) { $receivable->payment = 'Cash'; } else { $receivable->payment = 'Installment'; } $receivable->save(); $billable = Input::get('billable'); $payment = Input::get('payment'); if ((int) $payment > 0) { // First Installment $installment = new Installment(); $installment->project_id = Auth::user()->curr_project_id; $installment->location_id = Auth::user()->location_id; $installment->receivable_id = $receivable->id; $installment->schedule = Input::get('registration_date'); $installment->total = $billable / $payment; $installment->balance = $billable / $payment; $installment->paid = 0; $installment->save(); // Extracting Date $dd = (int) substr(Input::get('registration_date'), 8, 2); $mm = (int) substr(Input::get('registration_date'), 5, 2); $yy = (int) substr(Input::get('registration_date'), 0, 4); if ($dd > 25) { $mm += 2; if ($mm > 12) { $new_mm = $mm - 12; $yy += 1; } else { $new_mm = $mm; } } else { $mm += 1; if ($mm > 12) { $new_mm = $mm - 12; $yy += 1; } else { $new_mm = $mm; } } for ($i = 2; $i <= $payment; $i++) { $installment_date = $yy . '-' . str_pad($new_mm, 2, "0", STR_PAD_LEFT) . '-' . '05'; $installment = new Installment(); $installment->project_id = Auth::user()->curr_project_id; $installment->location_id = Auth::user()->location_id; $installment->receivable_id = $receivable->id; $installment->schedule = date('Y-m-d', strtotime($installment_date)); $installment->total = $billable / $payment; $installment->balance = $billable / $payment; $installment->paid = 0; $installment->save(); $new_mm += 1; if ($new_mm > 12) { $new_mm = $new_mm - 12; $yy += 1; } } } // Placements $courses = Input::get('course'); foreach ($courses as $key => $value) { $course = explode("#", $value); $placement = new Placement(); $placement->project_id = Auth::user()->curr_project_id; $placement->location_id = Auth::user()->location_id; $placement->registration_id = $registration->id; $placement->issue_id = $issue->id; $placement->course_id = $course[0]; $placement->save(); } // Reductions - Discounts $discounts = Input::get('discounts'); if ($discounts) { foreach ($discounts as $key => $value) { $discount = explode("#", $value); $reduction = new Reduction(); $reduction->project_id = Auth::user()->curr_project_id; $reduction->location_id = Auth::user()->location_id; $reduction->registration_id = $registration->id; $reduction->receivable_id = $receivable->id; $reduction->reductable_type = 'Discount'; $reduction->reductable_id = $discount[0]; $reduction->save(); } } // Reductions - Promotions $promotions = Input::get('promotions'); if ($promotions) { foreach ($promotions as $key => $value) { $promotion = explode("#", $value); $reduction = new Reduction(); $reduction->project_id = Auth::user()->curr_project_id; $reduction->location_id = Auth::user()->location_id; $reduction->registration_id = $registration->id; $reduction->receivable_id = $receivable->id; $reduction->reductable_type = 'Promotion'; $reduction->reductable_id = $promotion[0]; $reduction->save(); } } // Reductions - Vouchers $vouchers = Input::get('vouchers'); if ($vouchers) { foreach ($vouchers as $key => $value) { $voucher = explode("#", $value); $reduction = new Reduction(); $reduction->project_id = Auth::user()->curr_project_id; $reduction->location_id = Auth::user()->location_id; $reduction->registration_id = $registration->id; $reduction->receivable_id = $receivable->id; $reduction->reductable_type = 'Voucher'; $reduction->reductable_id = $voucher[0]; $reduction->save(); } } // Reductions - Charges $charges = Input::get('charges'); if ($charges) { foreach ($charges as $key => $value) { $charger = explode("#", $value); $reduction = new Reduction(); $reduction->project_id = Auth::user()->curr_project_id; $reduction->location_id = Auth::user()->location_id; $reduction->registration_id = $registration->id; $reduction->receivable_id = $receivable->id; $reduction->reductable_type = 'Charge'; $reduction->reductable_id = $charger[0]; $reduction->save(); } } // Updating Student Timelines $content = 'Bergabung menjadi Siswa One School ' . Auth::user()->location->name . 'untuk periode ' . Auth::user()->curr_project->name; $timeline = new Timeline(); $timeline->project_id = Auth::user()->curr_project_id; $timeline->location_id = Auth::user()->location_id; $timeline->informable_type = 'Issue'; $timeline->informable_id = $issue->id; $timeline->content = $content; $timeline->save(); // Updating Employee Timeline $content = 'Menerima Pendaftaran Siswa untuk periode ' . Auth::user()->curr_project->name; $timeline = new Timeline(); $timeline->project_id = Auth::user()->curr_project_id; $timeline->location_id = Auth::user()->location_id; $timeline->informable_type = 'Employee'; $timeline->informable_id = Input::get('employee'); $timeline->content = $content; $timeline->save(); //DB::commit(); return Response::json(array('status' => 'Succeed', 'registration_id' => $registration->id, 'issue_id' => $issue->id)); } catch (Exception $e) { DB::rollback(); return Response::json(array('status' => 'Failed', 'error' => $e)); } }
//Adds a new course to courses table. $app->post("/courses", function () use($app) { $id = null; $course = new Course($_POST['course_name'], $id, $_POST['course_number']); $course->save(); return $app['twig']->render('courses.html.twig', array('courses' => Course::getAll())); }); //Listing all students for a selected course. Check all_students variable for error issue $app->get("/courses/{id}", function ($id) use($app) { $course = Course::find($id); return $app['twig']->render('course.html.twig', array('course' => $course, 'students' => $course->getStudents(), 'all_students' => Student::getAll())); }); // $app->post("/add_courses", function () use($app) { $course = Course::find($_POST['course_id']); $student = Student::find($_POST['student_id']); $student->addCourse($course); return $app['twig']->render('student.html.twig', array('student' => $student, 'students' => Student::getAll(), 'courses' => $student->getCourses(), 'all_courses' => Course::getAll())); }); // $app->post("/delete_courses", function () use($app) { Course::deleteAll(); return $app['twig']->render('index.html.twig'); }); //Updates course, comes from course.html, posts back to courses.html $app->patch("/course/{id}/edit", function ($id) use($app) { $new_course_name = $_POST['new_course_name']; $course = Course::find($id); $course->update($new_course_name); return $app['twig']->render('courses.html.twig', array('courses' => Course::getAll())); });
/** * Returns the collection to which the user belongs * * @param $user User * @return Object */ public static function getUser($user) { if (strcmp($user->rank, 'university') === 0) { return University::find($user->_id); } else { if (strcmp($user->rank, 'teacher') === 0) { return Teacher::find($user->_id); } else { if (strcmp($user->rank, 'student') === 0) { return Student::find($user->_id); } else { return null; } } } }
function test_find() { //Arrange $student_name = "Bob"; $enroll_date = "2012-10-20"; $id = null; $test_student = new Student($student_name, $enroll_date, $id); $test_student->save(); $student_name2 = "Sue"; $enroll_date2 = "2013-09-09"; $test_student2 = new Student($student_name2, $enroll_date2, $id); $test_student2->save(); //Act $id = $test_student->getId(); $result = Student::find($id); //Assert $this->assertEquals($test_student, $result); }
function testFind() { //Arrange $name = "Sandra Maley"; $enrollment_date = "2016-04-29"; $name2 = "Margaret Sinclair"; $enrollment_date2 = "2017-11-30"; $test_student = new Student($name, $enrollment_date); $test_student->save(); $test_student2 = new Student($name2, $enrollment_date2); $test_student2->save(); //Act $result = Student::find($test_student->getId()); //Assert $this->assertEquals($test_student, $result); }
function test_find() { //Arange $name = "Steve Beekman"; $date = "2015-08-23"; $test_student = new Student($name, $date); $test_student->save(); $name2 = "Fred Flintstone"; $date2 = "0001-01-01"; $test_student2 = new Student($name2, $date2); $test_student2->save(); //Act $result = Student::find($test_student->getId()); //Assert $this->assertEquals($test_student, $result); }
function testFind() { //Arrange $id = null; $name = "Micah"; $enrollment_date = "2015-08-28"; $test_student = new Student($id, $name, $enrollment_date); $test_student->save(); $name2 = "Phil"; $enrollment_date2 = "2015-04-01"; $test_student2 = new Student($id, $name2, $enrollment_date2); $test_student2->save(); //Act $result = Student::find($test_student->getId()); //Assert $this->assertEquals($test_student, $result); }
<div class="panel" style="background-color: {{ $colors[$index] }}; color: white;"> <div class="panel-heading"> <div class="row"> <div class="col-xs-3"> <i class="fa fa-group fa-5x"></i> </div> <div class="col-xs-9 text-right"> <div class="huge">{{ $group->name }}</div> <div>{{ strtoupper($group->project_name) }}</div> </div> </div> </div> <div class="panel-footer" style="color: #000000;"> @foreach($group->students_id as $student) <?php $member = Student::find($student); ?> {{ $member->name.' '.$member->last_name }} @if($student == $group->teamleader_id) - TeamLeader @endif <a href="#" onclick="fillModal('{{$member->email}}')" data-toggle="modal" data-target="#studentDetailsModal"> <i class="fa fa-external-link"></i></a><br> @endforeach <br><br> <a href="#" class="show_group_detail" id="{{ $group->_id }}"> <span class="pull-left"> {{ Lang::get('teacher_section_groups.show_details') }} </span> <span class="pull-right"> <i class="fa fa-arrow-circle-right"></i>
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $issue = Issue::find($id); if ($issue == NULL) { throw new Exception('Invalid Book ID'); } $issue->added_at_timestamp = date('d-M-y h:i A', strtotime($issue->added_at_timestamp)); $book = Books::find($issue->book_id); $issue->book_name = $book->title; $issue->author = $book->author; $issue->category = Categories::find($book->category_id)->category; $issue->available_status = (bool) $issue->available_status; if ($issue->available_status == 1) { return $issue; } $conditions = array('return_time' => 0, 'book_issue_id' => $id); $book_issue_log = Logs::where($conditions)->take(1)->get(); foreach ($book_issue_log as $log) { $student_id = $log->student_id; } $student_data = Student::find($student_id); unset($student_data->email_id); unset($student_data->books_issued); unset($student_data->approved); unset($student_data->rejected); $student_branch = Branch::find($student_data->branch)->branch; $roll_num = $student_data->roll_num . '/' . $student_branch . '/' . substr($student_data->year, 2, 4); unset($student_data->roll_num); unset($student_data->branch); unset($student_data->year); $student_data->roll_num = $roll_num; $student_data->category = StudentCategories::find($student_data->category)->category; $issue->student = $student_data; return $issue; }
function eliminar($id) { if ($this->session->userdata('grupo') == 'admin') { $a = Student::find($id); $a->delete(); $this->session->set_flashdata('msg', '<div class="success">El alumno fué eliminado correctamente.</div>'); redirect('alumnos'); } else { $this->session->set_flashdata('msg', '<div class="error">No tiene permisos para realizar esta acción.</div>'); redirect('alumnos'); } }
}); $app->get("/students/{id}", function ($id) use($app) { $student = Student::find($id); return $app['twig']->render('student.html.twig', array('student' => $student, 'courses' => $student->getCourses(), 'all_courses' => Course::getAll())); }); $app->get("/students/{id}/edit", function ($id) use($app) { $student = Student::find($id); return $app['twig']->render('student_edit.html.twig', array('student' => $student)); }); $app->patch("/students/{id}", function ($id) use($app) { $name = $_POST['name']; $student = Student::find($id); $student->update($name); return $app['twig']->render('student.html.twig', array('student' => $student, 'courses' => $student->getCourses(), 'all_courses' => Course::getAll())); }); $app->post("/add_students", function () use($app) { $course = Course::find($_POST['course_id']); $student = Student::find($_POST['student_id']); $course->addStudent($student); return $app['twig']->render('course.html.twig', array('course' => $course, 'courses' => Course::getAll(), 'students' => $course->getStudents(), 'all_students' => Student::getAll())); }); $app->post("/delete_students", function () use($app) { Student::deleteAll(); return $app['twig']->render('index.html.twig'); }); $app->delete("/students/{id}", function ($id) use($app) { $student = Student::find($id); $student->delete(); return $app['twig']->render('students.html.twig', array('students' => Student::getAll())); }); return $app;
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function delete($id) { $student = Student::find($id); $student->isActive = "No"; $student->save(); return Redirect::to('/student/list')->with("success", "Student Deleted Succesfully."); }
function testFind() { //Arrange $name = "Math"; $date = '0000-00-00'; $id = null; $test_course = new Course($name, $id); $test_course->save(); $student_name = "Student1"; $id = 1; $course_id = $test_course->getId(); $test_student = new Student($student_name, $id, $date, $course_id); $test_student->save(); $student_name2 = "Student2"; $id2 = 2; $course_id2 = $test_course->getId(); $test_student2 = new Student($student_name2, $id2, $date, $course_id2); $test_student2->save(); //Act $result = Student::find($test_student->getId()); //Assert $this->assertEquals($test_student, $result); }
public function create_incident() { if (Auth::check()) { $data["inside_url"] = Config::get('app.inside_url'); $data["user"] = Session::get('user'); $data["actions"] = Session::get('actions'); if (in_array('side_nueva_anotacion', $data["actions"])) { $current_ay = AcademicYear::getCurrentAcademicYear(); if (!$current_ay) { return View::make('control_notebook_incidents/academic_year_error', $data); } // Validate the info, create rules for the inputs $attributes = array('type' => 'Tipo de anotación', 'description' => 'Redacción de la anotación'); $messages = array(); $rules = array('description' => 'required|max:300'); // Run the validation rules on the inputs from the form $validator = Validator::make(Input::all(), $rules, $messages, $attributes); // If the validator fails, redirect back to the form if ($validator->fails()) { return Redirect::to('control_notebook_incidents/new_incident')->withErrors($validator)->withInput(Input::all()); } else { $level_id = Input::get('level_id'); if ($level_id) { $student_id = Input::get('student_id'); if ($student_id) { // se crea la anotacion $incident = new ControlNotebookIncident(); $incident->type = Input::get('type'); $incident->description = Input::get('description'); $incident->date = date('Y-m-d'); $incident->teacher_id = $data["user"]->teacher->id; $incident->enrollment_id = Student::find($student_id)->getCurrentEnrollment()->id; $incident->save(); Session::flash('message', 'Se registró correctamente la anotación.'); // Llamo a la función para registrar el log de auditoria $log_description = "Se creó la Anotación con id: {{$incident->id}}"; Helpers::registerLog(3, $log_description); return Redirect::to('control_notebook_incidents/view_incidents')->withInput(Input::all()); } else { Session::flash('error', 'Debe seleccionar un Alumno.'); return Redirect::to('control_notebook_incidents/new_incident')->withInput(Input::all()); } } else { Session::flash('error', 'Debe seleccionar un Nivel.'); return Redirect::to('control_notebook_incidents/new_incident')->withInput(Input::all()); } } } else { // Llamo a la función para registrar el log de auditoria $log_description = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'"; Helpers::registerLog(10, $log_description); Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.'); return Redirect::to('/dashboard'); } } else { return View::make('error/error'); } }