本文整理汇总了PHP中Teacher::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Teacher::find方法的具体用法?PHP Teacher::find怎么用?PHP Teacher::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Teacher
的用法示例。
在下文中一共展示了Teacher::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addSectionCode
public function addSectionCode()
{
$section_code = new SectionCode();
$teacher = Teacher::find(Auth::Id());
$subject_id = Input::get('subject');
$section_id = Input::get('section');
$current_period = Input::get('current_period');
$section_code->teacher_id = new MongoId($teacher->_id);
$section_code->subject_id = new MongoId($subject_id);
$section_code->section_id = new MongoId($section_id);
$section_code->current_period = $current_period;
$section_code->teamleaders_id = array();
$section_code->students_id = array();
$section_code->status = true;
$subject = Subject::find($subject_id);
$section = $subject->sections()->find($section_id);
$code = $this->getInitialLetters($subject->name) . '-' . $section->code . '-' . $current_period;
$section_code->code = $code;
if (!is_null($section->current_code)) {
$sectionCode = SectionCode::where('code', $section->current_code)->first();
if (isset($sectionCode->_id)) {
$sectionCode->status = false;
$sectionCode->save();
}
}
try {
$section_code->save();
$section->current_code = $code;
$section->save();
} catch (MongoDuplicateKeyException $e) {
return Redirect::back()->withErrors(array('error' => Lang::get('section_codes.duplicate_code')));
}
return Redirect::to(Lang::get('routes.section_codes'))->with(array('message' => Lang::get('section_codes.success_message')));
}
示例2: getLastTitleId
public static function getLastTitleId()
{
try {
return Teacher::find(self::$lastTeacherId)->title->title_id;
} catch (Exception $e) {
return 'all';
}
}
示例3: getSubjectSections
/**
* Return the sections belonging to a teacher
*
* @return JSON Ajax
*/
public function getSubjectSections()
{
if (Request::ajax()) {
$subject = Subject::where("_id", new MongoId(Input::get("_id")))->first();
$teacher = Teacher::find(Auth::id());
$sections = $subject->sections()->whereIn('_id', $teacher->sections_id)->get();
if (count($sections) > 0) {
return Response::json(array('subject' => $subject->_id, 'sections' => $sections));
}
}
}
示例4: syncTeacher
/**
* 同步更新教師的班級資料
*/
public static function syncTeacher()
{
$classes = Classes::find(self::$lastClassesId);
try {
$teacher = Teacher::where('classes_id', '=', $classes->classes_id)->update(array('classes_id' => 0));
if ($classes->teacher_id > 0) {
$teacher = Teacher::find($classes->teacher_id)->update(array('classes_id' => $classes->classes_id));
}
} catch (Exception $e) {
}
}
示例5: unlink
/**
* Unlink a section with a teacher
*
* @return JSON Ajax
*/
public function unlink()
{
if (Request::ajax()) {
$subject = Subject::find(Input::get('subject_id'));
$teacher = Teacher::find(Input::get('teacher_id'));
$teacher->pull('sections_id', new MongoId(Input::get('section_id')));
$section = $subject->sections()->find(Input::get('section_id'));
$section->is_free = true;
$section->save();
if ($subject->sections()->whereIn('_id', $teacher->sections_id)->count() === 0) {
$teacher->pull('subjects_id', new MongoId(Input::get('subject_id')));
}
return Response::json("00");
}
}
示例6: 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));
}
示例7: function
$teacherList = $titleId == 'all' ? Teacher::orderBy('teacher_name') : Teacher::where('title_id', '=', $titleId)->orderBy('teacher_name');
$viewData['teacherList'] = $teacherList->get();
$viewData['titleList'] = Title::orderBy('title_name')->get();
$viewData['titleId'] = $titleId;
$viewData['teacher'] = Teacher::find($teacherId);
$viewData['teacherId'] = $teacherId;
$viewData['courseUnits'] = $viewData['teacher']->courseunit;
return View::make('timetable')->with($viewData);
});
// 顯示教師排課編輯畫面
Route::get('view_title/{titleId}/{teacherId}/{courseUnitId}', function ($titleId, $teacherId, $courseUnitId) {
$teacherList = $titleId == 'all' ? Teacher::orderBy('teacher_name') : Teacher::where('title_id', '=', $titleId)->orderBy('teacher_name');
$viewData['teacherList'] = $teacherList->get();
$viewData['titleList'] = Title::orderBy('title_name')->get();
$viewData['titleId'] = $titleId;
$viewData['teacher'] = Teacher::find($teacherId);
$viewData['teacherId'] = $teacherId;
$viewData['courseUnits'] = $viewData['teacher']->courseunit;
$viewData['courseUnit'] = Courseunit::find($courseUnitId);
return View::make('timetable')->with($viewData);
});
// 執行更新排課設定
Route::post('edit/{titleId}/{teacherId}/{courseUnitId}', function ($titleId, $teacherId, $courseUnitId) {
// 設定為編輯模式,方便驗證功能
$validator = FormValidator::courseUnit(array_merge(Input::all(), array('mode' => 'edit' . $courseUnitId)));
if ($validator->fails()) {
return Redirect::to('/timetable/view_title/' . $titleId . '/' . $teacherId . '/' . $courseUnitId)->withInput()->withErrors($validator)->with('message', '輸入錯誤,請檢查');
} else {
$data = Input::all();
$courseUnit = Courseunit::find($courseUnitId);
if ($courseUnit->update($data)) {
示例8:
<div class="offset2 span3">
<div class="control-group">
<label class="control-label">Created Date</label>
<div class="controls">
<span class="input-xlarge uneditable-input">{{ $tutorial->created_at }}</span>
</div>
</div>
<label class="control-label">Updated Date</label>
<div class="controls">
<span class="input-xlarge uneditable-input">{{ $tutorial->updated_at }}</span>
</div>
<label class="control-label">Created By</label>
<div class="controls">
<span class="input-xlarge eneditable-input">
<?php
$teacher = Teacher::find($tutorial->createdby);
$username = Sentry::findUserByLogin($teacher->email);
echo $username->first_name . ' ' . $username->last_name;
?>
</span>
</div><br>
<label class="control-label">Current Attachments</label>
<table class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th>#id</th>
<th>Name</th>
<th>Action</th>
</tr>
</thead>
<tbody>
示例9: teacherMore
public function teacherMore()
{
$teacher_id = Input::get('teacher_id');
$teacher = Teacher::find($teacher_id);
return View::make('home.comedy.comedy-details')->with(array('teacher' => $teacher, 'links' => $this->link()));
}
示例10: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
// self::requestOriginalApi('/api/teachers', "DELETE");
// return Redirect::to('admin/teachers');
$teacher = Teacher::find($id);
$teacher->delete();
return Redirect::to('admin/teachers');
}
示例11:
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
{{ $header }}
<div class='container-fluid'>
<div class='row-fluid'>
<div class="span3 offset2">
<?php
$user = User::find($id);
$userdata = Student::find($id);
$userstream = 'student';
if ($userdata == NULL) {
$userdata = Teacher::find($id);
$userstream = 'teacher';
} else {
$userdata;
}
?>
<div class="pull-left">
First Name -
</div>
<div class="pull-right">
{{$user->first_name}}
</div><br> <br>
<div class="pull-left">
Last Name -
</div>
<div class="pull-right">
示例12: showReportView
public function showReportView()
{
$teacher = Teacher::find(Auth::id());
$subjects = Subject::whereIn('_id', $teacher->subjects_id)->get();
$section_codes = SectionCode::where('teacher_id', new MongoId($teacher->_id))->where('status', true)->get();
return View::make('teacher.report')->with(array('subjects' => $subjects, 'teacher_section_id' => $teacher->sections_id, 'section_codes' => $section_codes));
}
示例13: deleteTeacher
public function deleteTeacher()
{
${$teacher_id} = Input::get('$teacher_id');
$teacher = Teacher::find($teacher_id);
if (!$teacher_id->delete()) {
return Response::json(array('errCode' => 1, 'message' => '删除失败!'));
}
return Response::json(array('errCode' => 0, 'message' => '删除成功!'));
}
示例14:
<div class="navbar-default sidebar" role="navigation">
<div class="sidebar-nav navbar-collapse">
<ul class="nav" id="side-menu">
<li>
<a href="{{Lang::get('routes.teacher')}}" class="nav_home_categoria" style="background-color: #0097A7; color: white;">
<i class="fa fa-home"></i> {{Lang::get('teacher_master.board')}}
</a>
</li>
<li>
<a href="#" class="nav_categoria">
<i class="fa fa-list"></i>
{{Lang::get('teacher_master.subject')}}
</a>
<ul class="nav nav-second-level">
<?php
$teacher = Teacher::find(Auth::id());
$subjects = Subject::whereIn('_id', $teacher->subjects_id)->get();
?>
@foreach($subjects as $subject)
<li>
<a href="#">
<i class="fa fa-eye" style="color: #0097A7;"></i>
{{ $subject->name }}
</a>
<ul class="nav nav-third-level">
<?php
$sections = $subject->sections()->whereIn('_id', $teacher->sections_id)->get();
?>
@foreach($sections as $section)
<li>
<a href="#" id="{{$section->current_code}}" class="menu_section">
示例15: updateUser
private function updateUser($user, $group)
{
$accountlevel = Input::get('accountlevel');
$useradminupgrade = array();
$useradminupgrade['enabled'] = 0;
$useradminupgrade['from'] = 'teachers';
switch ($group) {
case 'teachers':
if ($accountlevel == 'admin') {
$useradminupgrade['enabled'] = 1;
$useradminupgrade['from'] = 'teachers';
break;
}
$updateableuserid = $user->id;
$user = User::find($user->id);
$updateableuser = Student::find($user->id);
$userstream = 'student';
if ($updateableuser == NULL) {
$updateableuser = Teacher::find($user->id);
$userstream = 'teacher';
}
$updateduser = self::setAccountLevel($accountlevel);
$updateduser->email = $updateableuser->email;
$updateduser->dob = $updateableuser->dob;
$updateableuser->extra = $updateableuser->extra;
$updateduser->user_id = $updateableuser->user_id;
$newuser = Sentry::findUserById($user->id);
$newusergroup = self::setUserGroup($accountlevel);
$oldusergroup = Sentry::findGroupByName('teachers');
$newuser->removeGroup($oldusergroup);
$newuser->addGroup($newusergroup);
//Save NEW User
$updateduser->save();
//Delete OLD User
$updateableuser->delete();
break;
case 'students':
if ($accountlevel == 'admin') {
$useradminupgrade['enabled'] = 1;
$useradminupgrade['from'] = 'students';
break;
}
$updateableuserid = $user->id;
$user = User::find($user->id);
$updateableuser = Student::find($user->id);
$userstream = 'student';
if ($updateableuser == NULL) {
$updateableuser = Teacher::find($user->id);
$userstream = 'teacher';
}
$updateduser = self::setAccountLevel($accountlevel);
$updateduser->email = $updateableuser->email;
$updateduser->dob = $updateableuser->dob;
$updateduser->extra = $updateableuser->extra;
$updateduser->user_id = $updateableuser->user_id;
$newuser = Sentry::findUserById($user->id);
$newusergroup = self::setUserGroup($accountlevel);
$oldusergroup = Sentry::findGroupByName('students');
$newuser->removeGroup($oldusergroup);
$newuser->addGroup($newusergroup);
//Delete OLD User
$updateableuser->delete();
//Save NEW User
$updateduser->save();
break;
case 'admin':
if ($accountlevel == 'admin') {
$useradminupgrade['enabled'] = 1;
$useradminupgrade['from'] = 'admin';
}
$updateableuserid = $user->id;
$newuser = Sentry::findUserById($updateableuserid);
$newusergroup = self::setUserGroup($accountlevel);
$oldusergroup = Sentry::findGroupByName('admin');
$newuser->removeGroup($oldusergroup);
$newuser->addGroup($newusergroup);
break;
}
if ($useradminupgrade['enabled'] == 1) {
switch ($useradminupgrade['from']) {
case 'teachers':
$updateableuserid = $user->id;
$newuser = Sentry::findUserById($updateableuserid);
$newusergroup = self::setUserGroup('admin');
$oldusergroup = Sentry::findGroupByName('students');
$newuser->removeGroup($oldusergroup);
$newuser->addGroup($newusergroup);
break;
case 'students':
$updateableuserid = $user->id;
$newuser = Sentry::findUserById($updateableuserid);
$newusergroup = self::setUserGroup('admin');
$oldusergroup = Sentry::findGroupByName('students');
$newuser->removeGroup($oldusergroup);
$newuser->addGroup($newusergroup);
}
}
}