本文整理汇总了PHP中Classes::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Classes::find方法的具体用法?PHP Classes::find怎么用?PHP Classes::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Classes
的用法示例。
在下文中一共展示了Classes::find方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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) {
}
}
示例2: postSaveTimetable
public function postSaveTimetable()
{
if (Request::ajax()) {
$class = Classes::find(Input::get('id'));
$times = Input::get('time');
$times = substr($times, 1, -1);
$class->classtimes = $times;
if ($class->save()) {
return Response::json('success', 200);
}
}
}
示例3: json_decode
<div class="row">
<hr class="metro-hr">
<div class="col-sm-9">
<div class="form-group">
<i class="fa fa-calendar"></i>
<input type="text" name="electimes" id="elective" list="electives" class="form-control" placeholder="Choose Elective Module to view Timetable" required="">
<datalist id="electives">
<select onchange="$('#elective').val(this.value)">
<?php
$electives = Auth::user()->electives;
if ($electives != null) {
$electives = json_decode($electives);
//Search for current elective.
foreach ($electives as $key => $value) {
$elec = Classes::find($value->classId);
$mod = Modules::find($elec->classmodule);
print '<option class="myclass' . $value->classId . '" label="' . $mod->mshorttitle . '" value="' . $elec->classid . '"></option>';
}
}
?>
</select>
</datalist>
</div>
</div>
<div class="col-sm-3">
<ul class="check-our-work">
<a data-toggle="modal" class="submit btn btn-info btn-block" role="button" id="loadTimes">Load Timetable</a>
</ul>
</div>
<hr class="metro-hr">
示例4: function
return Redirect::to('/class_year/view_year/' . $yearId)->withInput()->withErrors($validator)->with('message', '輸入錯誤,請檢查');
} else {
$data = Input::all();
$year = Classes::find($classesId);
if ($year->update($data)) {
$message = '更新《' . $data['classes_name'] . '》完成';
} else {
$message = '資料寫入錯誤';
}
Classes::syncTeacher();
return Redirect::to('/class_year/view_year/' . $yearId)->with('message', $message);
}
});
// 執行刪除班級
Route::get('/delete_classes/{classesId}/{yearId}', function ($classesId, $yearId) {
$classes = Classes::find($classesId);
$message = '刪除《' . $classes->classes_name . '》完成';
$classes->delete();
return Redirect::to('/class_year/view_year/' . $yearId)->with('message', $message);
});
// 執行刪除年級
Route::get('/delete_year/{yearId}', function ($yearId) {
$year = Year::find($yearId);
$message = '刪除《' . $year->year_name . '》完成';
$year->delete();
return Redirect::to('/class_year')->with('message', $message);
});
});
/**
* 課程管理
*/
示例5: deleteAction
public function deleteAction()
{
$input = Input::all();
$id = $input["id"];
$schoolToClass = DB::table('schoolclass')->where('class', $id);
$classToStudent = DB::table('classstudent')->where('class', $id);
$status = false;
if ($schoolToClass->count() < 1 && $classToStudent->count() < 1) {
$class = Classes::find($id);
$class->deleted_at = new DateTime(date('Y-m-d H:i:s'));
$class->save();
$status = true;
$message = "";
} else {
$message = "Sorry. You cannot delete this class. \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);
}
开发者ID:AxelPardemann,项目名称:E-Learning-System-based-on-Laravel-and-Bootstrap,代码行数:19,代码来源:ClassController.php
示例6: courseUnit
/**
* 驗證排課單元
*/
public static function courseUnit($data)
{
// 衝突檢查
Validator::extend('conflict', function ($attribute, $data, $parameters) {
/* Array參考
[0][_token] => Yvw1pYLjZIm1BaiPJ1yTYKbs3Nl8T9zfkLesI0Bh
[1][classes_id] => 4
[2][course_id] => 9
[3][count] => 1
[4][classroom_id] => 0
[5][combination] => 1
[6][repeat] => 0
[7][limit_course_time] => 1
[8][course_time] => 10000001000000110000011000001100000
[9][teacher_id] => 19
*/
// 處理變數
list(, $classes_id, $course_id, $count, $classroom_id, $combination, $repeat) = $parameters;
$mode = end($parameters);
$teacher_id = prev($parameters);
if (substr($mode, 0, 4) == 'edit') {
$courseUnitId = intval(substr($mode, 4));
$mode = substr($mode, 0, 4);
}
if ($parameters[7] == 1) {
$course_time = $parameters[8];
} else {
$course_time = 0;
}
// 限制排課時間少於設定節數
if (substr_count($course_time, '1') < $count && substr_count($course_time, '1') != 0) {
Session::flash('conflictError', '限制排課時間(共' . substr_count($course_time, '1') . '節)少於設定節數(' . $count . ')');
return false;
}
// 組合節數大於設定節數
if ($combination > $count) {
Session::flash('conflictError', '組合節數(' . $combination . ')大於設定節數(' . $count . ')');
return false;
}
// 同天不排課,但是(排課節數 / 組合節數)超過5
if ($repeat == 0 && $count / $combination > 5) {
Session::flash('conflictError', '同天同班不重複排課,但是(排課節數 / 組合節數)超過5');
return false;
}
// 教室可排課時間不足
if ($classroom_id != 0) {
$courseCount = 0;
$courseUnitUseClassroom = array();
foreach (Courseunit::where('classroom_id', '=', $classroom_id)->get() as $courseunit) {
$courseCount += $courseunit->count;
$courseUnitUseClassroom[] = $courseunit->teacher->teacher_name;
}
$classroom = Classroom::find($classroom_id);
// 檢查是否為編輯模式
if ($mode == 'edit') {
$courseUnit = Courseunit::find($courseUnitId);
if ($courseUnit->classroom_id == $classroom_id) {
$courseCount -= $courseUnit->count;
}
}
if (substr_count($classroom->course_time, '1') * $classroom->count - $courseCount - $count < 0) {
$teacherList = implode($courseUnitUseClassroom, ',');
Session::flash('conflictError', '教室《' . $classroom->classroom_name . '》可排課時間不足,目前有使用的老師:' . $teacherList);
return false;
}
}
// 班級可排節數已滿
$classesCourseCount = 0;
foreach (Courseunit::where('classes_id', '=', $classes_id)->get() as $courseunit) {
$classesCourseCount += $courseunit->count;
}
// 編輯模式
if ($mode == 'edit') {
$courseUnit = Courseunit::find($courseUnitId);
if ($courseUnit->classes_id == $classes_id) {
$classesCourseCount -= $courseUnit->count;
}
}
$classes = Classes::find($classes_id);
if (substr_count($classes->year->course_time, '1') - $classesCourseCount - $count < 0) {
Session::flash('conflictError', '班級《' . $classes->classes_name . '》可排課時間不足');
return false;
}
return true;
});
$rules = array('teacher_id' => 'required|integer', 'course_id' => 'required|integer', 'classroom_id' => 'required|integer', 'count' => 'required|integer', 'combination' => 'required|integer|conflict:' . implode(',', $data), 'repeat' => 'required|integer', 'course_time' => 'numeric');
$messages = array('required' => '此欄位必填', 'integer' => '必需為數字', 'conflict' => '排課衝突');
return Validator::make($data, $rules, $messages);
}
示例7: array
}));
//Route to new class for administrator
Route::get("classes", array("as" => "admin/classes", function () {
$user = Auth::user();
$classes = DB::table('classes')->where('deleted_at', NULL)->get();
return View::make("admin.classes")->with("title", "Class")->with("sub_title", "classall")->with("classes", $classes)->with("user", $user);
}));
Route::get("classAdd", array("as" => "admin/classAdd", function () {
$user = Auth::user();
$schools = DB::table('school')->where('deleted_at', NULL)->get();
return View::make("admin.class_new")->with("title", "Class")->with("sub_title", "classnew")->with("schools", $schools)->with("user", $user);
}));
Route::get("classEdit/{id}", array("as" => "admin/classEdit", function ($id) {
$user = Auth::user();
//$id = Session::get('id');
$classByID = Classes::find($id);
$schools = DB::table('school')->where('deleted_at', NULL)->get();
$included_schools = DB::table('schoolclass')->where('class', $id)->get();
$school_array = array();
$i = 0;
foreach ($included_schools as $school) {
$school_array[$i] = $school->school;
$i++;
}
$students = array();
if (sizeof($school_array) > 0) {
$students = DB::table('users')->leftJoin('schooluser', 'users.id', '=', 'schooluser.user')->leftJoin('school', 'schooluser.school', '=', 'school.id')->whereIn('schooluser.school', $school_array)->orderBy('schooluser.school', 'asc')->select('users.id', 'users.first', 'users.last', 'school.name')->groupBy('schooluser.user')->get();
}
$courses = DB::table('courses')->where('published', 1)->where('deleted_at', NULL)->select('id', 'name', 'description')->get();
return View::make("admin.class_edit")->with("title", "Class")->with("sub_title", "classnew")->with("students", $students)->with("classByID", $classByID)->with("schools", $schools)->with("courses", $courses)->with("user", $user);
}));
示例8: postDeleteStreams
public function postDeleteStreams()
{
$new_stream = Input::get('stream_id');
$stream_name = Input::get('stream_name');
if ($new_stream) {
$streams = Streams::find($new_stream);
} else {
$streams = Streams::where('stream_name', '=', $stream_name);
}
$classes = Classes::where('streams_id', '=', $streams->id)->get();
if ($streams->delete()) {
foreach ($classes as $class) {
Classes::find($class->id)->delete();
}
$response = array('status' => 'success', 'msg' => 'Setting created successfully', 'deleted_item_id' => $new_stream);
return Response::json($response);
} else {
$response = array('status' => 'failed', 'msg' => 'Item is Not deleted', 'Item_id' => $new_stream);
return Response::json($response);
}
}
示例9: getSchoolStudents
public function getSchoolStudents()
{
$query = "select\n users.id,\n users.school_id,\n user_details.username,\n user_details.first_name,\n user_details.last_name,\n users_to_class.class_id,\n users_to_class.section_id,\n user_details.pic\n from users\n join users_groups\n on users.id=users_groups.user_id and users_groups.groups_id=? and users.school_id=?\n join user_details\n on users.id=user_details.user_id\n join users_to_class\n on users_to_class.user_id=users.id";
$all_school_users = DB::select($query, array(2, $this->getSchoolId()));
$i = 0;
foreach ($all_school_users as $all_school_user) {
$class = Classes::find($all_school_user->class_id)->get()->first();
$all_users[$i]['class_name'] = $class->class;
$section = Sections::find($all_school_user->section_id);
$all_users[$i]['section_name'] = $section->section_name;
$all_users[$i]['username'] = $all_school_user->username;
$all_users[$i]['first_name'] = $all_school_user->first_name;
$all_users[$i]['last_name'] = $all_school_user->last_name;
$all_users[$i]['pic'] = $all_school_user->pic;
$all_users[$i]['id'] = $all_school_user->id;
$all_users[$i]['school_id'] = $all_school_user->school_id;
$i++;
}
return View::make('admin.school-students')->with('users', $all_users);
}