本文整理汇总了PHP中Student::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Student::find方法的具体用法?PHP Student::find怎么用?PHP Student::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Student
的用法示例。
在下文中一共展示了Student::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* 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;
}
示例2: run
/**
* 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();
}
示例3: childWingmanModules
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);
}
示例4: test_find
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);
}
示例5: testFind
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);
}
示例6: test_find
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);
}
示例7: sync
/**
* 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;
}
示例8: test_find
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);
}
示例9: testFind
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);
}
示例10: Welcome
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));
}
示例11: searchAction
/**
* 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();
}
示例12: forumId
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));
}
示例13: showView
/**
* 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));
}
示例14: test_find
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);
}
示例15: testFind
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);
}