本文整理汇总了PHP中app\Student::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Student::find方法的具体用法?PHP Student::find怎么用?PHP Student::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Student
的用法示例。
在下文中一共展示了Student::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
public function destroy($student_id)
{
$student = Student::find($student_id);
if ($student) {
$student->courses()->detach();
$student->delete();
return $this->createSuccessResponse("The student with id {$student_id} has been removed", 200);
}
return $this->createErrorResponse('The student with the specified id does not exists');
}
示例2: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$students = Student::find($id);
$faculties = Faculty::lists('faculty_name', 'faculty_code');
$studies = Study::lists('study_name', 'id');
$programStudies = ProgramStudy::lists('name', 'id');
$academicRegistrations = AcademicRegistration::lists('academic_year', 'id');
$religions = Religion::lists('name', 'id');
return view('dashboard.admin.student.edit', ['student' => $students, 'faculty' => $faculties, 'study' => $studies, 'programStudy' => $programStudies, 'academicRegistration' => $academicRegistrations, 'religion' => $religions]);
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(CreateParentRequest $request)
{
$parent = new Guardian(array('firstname' => $request->firstname, 'lastname' => $request->lastname, 'middlename' => $request->middle_name, 'phone' => $request->phone, 'district' => $request->district, 'home_address' => $request->home_address, 'office_address' => $request->office_address, 'occupation' => $request->occupation, 'email' => $request->email));
$student = \App\Student::find($request->student_id);
$parent = $student->guardians()->save($parent, ['relation' => $request->relation]);
if ($parent) {
return \Redirect::route('learners')->with('message', 'Parent successfuly registered!');
} else {
return \Redirect::route('learners')->with('error-message', 'Failed to register Parent!');
}
}
示例4: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$student = Student::find($id);
$student->sernum = $request->sernum;
$student->category_id = $request->category_id;
$student->lastname = $request->lastname;
$student->firstname = $request->firstname;
$student->email = $request->email;
$student->sernum = $request->sernum;
$student->save();
return redirect()->route('student.index');
}
示例5: sendVerifiactionMail
/**
* This function sends a verification
* mail with code to the students.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function sendVerifiactionMail()
{
// Get currently logged in student
$student = Student::find(Auth::guard('student')->user()->rollNo);
$verificationCode = $this->generateVerificationCode($student->rollNo);
$student->verificationCode = $verificationCode;
$student->save();
Mail::queue('student.auth.emails.verification', ['student' => $student], function ($msg) use($student) {
$msg->from('noreply@semesterregistration.com', 'Support');
$msg->to($student->email, $student->name)->subject('Your Verification code');
});
$statusMsg = 'Verification code successfully sent on ' . $student->email;
return redirect()->back()->with('status', $statusMsg);
}
示例6: destroy
public function destroy($course_id, $student_id)
{
$course = Course::find($course_id);
if ($course) {
$student = Student::find($student_id);
if ($student) {
if (!$course->students()->find($student->id)) {
return $this->createErrorResponse("The student with id {$student->id} does not exists in the course with id {$course->id}", 404);
}
$course->students()->detach($student->id);
return $this->createSuccessResponse("The student with id {$student->id} was removed from the course with id {$course->id}", 200);
}
return $this->createErrorResponse("The student with id {$student_id} does not exists", 404);
}
return $this->createErrorResponse("The course with id {$course_id}, does not exists", 404);
}
示例7: ucenik
public function ucenik($id)
{
//
$student = Student::find($id);
$ulogovani_user_id = \Auth::user()->id;
$odabrani_razred_id = $student->category->id;
$odabrani_ucenik_id = $student->id;
$count = Report::where('user_id', '=', $ulogovani_user_id)->where('category_id', '=', $odabrani_razred_id)->where('student_id', '=', $odabrani_ucenik_id)->count();
if ($count < 1) {
return view('reports.create')->with('ulogovani_user_id', $ulogovani_user_id)->with('odabrani_razred_id', $odabrani_razred_id)->with('odabrani_ucenik_id', $odabrani_ucenik_id);
//return $count;
} else {
$report = Report::where('user_id', '=', $ulogovani_user_id)->where('category_id', '=', $odabrani_razred_id)->where('student_id', '=', $odabrani_ucenik_id)->first();
return view('reports.index')->with('report', $report);
}
}
示例8: postUpdate
public function postUpdate(Request $request, $id)
{
$inputs = $request->all();
$rules = ['phone' => 'required'];
$validator = Validator::make($inputs, $rules);
if ($validator->passes()) {
$student = Student::find($id);
$student->c_lxdh = $inputs['phone'];
$student->c_zyh = $inputs['major'];
if ($student->save()) {
return redirect('/')->with('status', '双学位报名成功');
} else {
return back()->withErrors('双学位报名失败');
}
} else {
return back()->withErrors($validator);
}
}
示例9: rollbackLog
public static function rollbackLog($id, $user, $review_ip)
{
$review_at = date('Y-m-d H:i:s', time());
$update_arr = array('review_name' => $user->name, 'review_email' => $user->email, 'review_ip' => $review_ip, 'review_at' => $review_at, 'review' => true, 'status' => '审核未通过');
$manage_log = self::find($id);
$before = json_decode($manage_log->before_info, true);
$after = json_decode($manage_log->after_info, true);
//Student
if ($manage_log->type == "新增信息") {
$student = Student::find($after['id']);
if (!$student) {
return "数据回滚失败:学号为" . $after['id'] . "的学生已不存在!";
}
$student->delete();
}
if ($manage_log->type == "修改信息") {
$data = array();
foreach ($before as $key => $value) {
if ($before[$key] != $after[$key]) {
$data[$key] = $before[$key];
}
}
$student = Student::find($after['id']);
if (!$student) {
return "数据回滚失败:学号为" . $after['id'] . "的学生已不存在!";
}
$student->update($data);
}
if ($manage_log->type == "删除信息") {
$student = Student::find($before['id']);
if ($student) {
return "数据回滚失败:已存在学号为" . $before['id'] . "的学生!";
}
Student::create($before);
}
$manage_log->update($update_arr);
}
示例10: updatePassword
/**
* Update user password
*
* @param Request $request
* @return mixed
*/
public function updatePassword(Request $request)
{
// Get the logged in user
$student = Student::find(Auth::guard('student')->user()->rollNo);
$newPassword = $request['password'];
// Validate the password
$this->validate($request, ['password' => 'required|min:8']);
// Save updated password
$student->password = bcrypt($newPassword);
$student->save();
return redirect()->back()->with('status', 'Success');
}
示例11: editStudent
public function editStudent(Request $request)
{
$id = $this->clean($request->input('id'));
$student = Student::find($id);
return view('student/delete_edit', array('student' => $student));
}
示例12: calculateStaffDiscount
/**
* @param int
* @param string
* @return double
*/
public static function calculateStaffDiscount($student_id, $fee_schedule_code)
{
//initialise discount to zero
$discount = 0;
//get stuednt info
$student = Student::find($student_id);
//get the staff discount value for this fee schedule
$staff_discount = self::getStaffDiscountAmount($fee_schedule_code);
//get details of staff discount policy
$discount_policy = DiscountPolicy::where('discount_name', 'Parent')->first();
//get all wards with same staff
$same_staff = Student::select('id')->where('staff_id', $student->staff_id)->get();
//divide staff discount accross all wards that have thesame staff
if ($discount_policy->all_wards == 1) {
$discount += $staff_discount / count($same_staff);
return $discount;
}
//dont divide staff discount accross all wards that have thesame staff
if ($discount_policy->dont_divide == 1) {
$discount += $staff_discount;
return $discount;
}
if ($discount_policy->all_wards == 0) {
$student_ids = [];
foreach ($same_staff as $stud) {
$student_ids[] = $stud->id;
}
sort($student_ids);
foreach ($student_ids as $key => $student_id) {
if ($key == $discount_policy->ward_to_deduct - 1) {
$ward_to_deduct = $student_id;
}
}
if ($ward_to_deduct == $student->id) {
$discount += $staff_discount;
}
return $discount;
}
}
示例13: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$student = Student::find($id);
$student->delete();
return redirect('/student');
}
示例14: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$student = Student::find($id);
$student->destroy();
return \Redirect::to('admin/students');
}
示例15: destroy
public function destroy($id)
{
$data = Student::find($id);
$data->delete();
return redirect()->route('student.index');
}