本文整理汇总了PHP中app\Student::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Student::where方法的具体用法?PHP Student::where怎么用?PHP Student::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Student
的用法示例。
在下文中一共展示了Student::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
$router->bind('students', function ($id) {
return \App\Student::where('id', $id)->firstOrFail();
});
parent::boot($router);
}
示例2: razredi
public function razredi($id)
{
$category = Category::find($id);
$students = Student::where('category_id', '=', $category->id)->get();
//return $category;
return view('reports.razred')->with('category->id', $category->id)->with('students', $students)->with('category', $category);
}
示例3: generate
public function generate($id)
{
$college = $this->checkCollege($id);
$students = Student::where('college', 'LIKE', '%' . $college . '%')->orderBy('lastname')->get();
$pdf = \PDF::loadView('layouts.spreadsheet', compact('students'));
//return view('layouts.spreadsheet', compact('students'));
return $pdf->download('test.pdf');
}
示例4: asyncRanking
public function asyncRanking(AjaxGameRequest $request)
{
//highestMark descending order first, and then recordDate ascending order
//$students = Student::where('highestMark', '>', 0)->orderBy('highestMark', 'DESC')->get();
$students = Student::where('highestMark', '>', 0)->orderBy('highestMark', 'DESC')->oldest('recordDate')->get();
//return response()->json($students);
return $students;
}
示例5: students
public function students()
{
if (!Session::has('admin')) {
return redirect('/admin/login');
}
$students = Student::where('validated', true)->get();
return view('admin/students', ['students' => $students]);
}
示例6: search
public function search()
{
$keyword = Input::get('keyword');
if (count(explode(" ", $keyword)) > 1) {
$students = Student::where('ime_studenta', 'LIKE', explode(" ", $keyword)[1] . '%')->where('priimek_studenta', 'LIKE', explode(" ", $keyword)[0] . '%')->orwhere('ime_studenta', 'LIKE', explode(" ", $keyword)[0] . '%')->where('priimek_studenta', 'LIKE', explode(" ", $keyword)[1] . '%')->get();
} else {
$students = Student::where('ime_studenta', 'LIKE', $keyword . '%')->orWhere('priimek_studenta', 'LIKE', $keyword . '%')->orWhere('vpisna_stevilka', $keyword)->get();
}
return view('seznamstudentov', ['students' => $students, 'tip' => Auth::user()->type]);
}
示例7: getIndex
public function getIndex()
{
if (Request::ajax()) {
$colleges = College::all();
$courses = Course::all();
$scholarships = Scholarship::all();
$students = Student::where('archived', 0)->get();
return compact('colleges', 'courses', 'scholarships', 'students');
}
}
示例8: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
parent::boot($router);
//versione semplice
//$router->model('users', \App\User::class);
//funziona sempre e anche per fare filtri su campi diversi da id
$router->bind('students', function ($id) {
return \App\Student::where('id', $id)->firstOrFail();
});
}
示例9: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(AddStudentRequest $request)
{
$id = $request->get('student_number');
$student = Student::where('student_number', $id)->first();
if (count($student) > 0) {
return response()->json(['success' => false, 'message' => 'Student number already exist']);
}
$student = Student::create(['student_number' => $request->get('student_number'), 'fname' => $request->get('fname'), 'lname' => $request->get('lname'), 'address' => $request->get('address'), 'zip' => $request->get('zip'), 'city' => $request->get('city'), 'state' => $request->get('state'), 'phone' => $request->get('phone'), 'mobile' => $request->get('mobile'), 'email' => $request->get('email'), 'year' => $request->get('year'), 'section_id' => $request->get('section_id'), 'dob' => $request->get('dob')]);
if (!$student->save()) {
return response()->json(['success' => false, 'message' => 'Failed to save record']);
}
return response()->json(['success' => true, 'message' => 'New student saved successfully!']);
}
示例10: natisni
public function natisni($vs)
{
$student = Student::where('vpisna_stevilka', $vs)->get();
$vpis = Vpis::where('vpisna_stevilka', $vs)->where('sifra_studijskega_leta', substr(date('Y'), 2, 2))->get();
$vse['vpisnastevilka'] = $vs;
$vse['priimekime'] = $student[0]->priimek_studenta . ', ' . $student[0]->ime_studenta;
$vse['datum'] = date("d.m.Y", strtotime($student[0]->datum_rojstva));
$vse['kraj'] = $student[0]->kraj_rojstva;
$vse['letnik'] = Letnik::where('sifra_letnika', $vpis[0]->sifra_letnika)->pluck('stevilka_letnika');
$vse['nacin'] = Nacin_studija::where('sifra_nacina_studija', $vpis[0]->sifra_nacina_studija)->pluck('opis_nacina_studija');
$vse['program'] = Studijski_program::where('sifra_studijskega_programa', $vpis[0]->sifra_studijskega_programa)->pluck('naziv_studijskega_programa');
$st = Input::get('stevilo') - 1;
return view('potrdiloovpisu', ['vse' => $vse, 'st' => $st]);
}
示例11: create
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
$user_request = UserRequest::where('token', $data['request_token'])->first();
if ($user_request->role == "Student") {
$user = Student::where('email', $user_request->email)->first();
} else {
if ($user_request->role == "Teacher") {
$user = Teacher::where('email', $user_request->email)->first();
}
}
$newUser = User::create(['name' => $user->name, 'email' => $user->email, 'password' => bcrypt($data['password'])]);
$newUser->roles()->attach($user_request->role);
$user_request->delete();
return $newUser;
}
示例12: save
public function save()
{
$user_request = new UserRequest();
$user_request->token = bin2hex(random_bytes(15));
$user_request->role = $this->string;
$user_request->email = $this->email;
$user_request->save();
if ($this->string == 'Student') {
$user = Student::where('email', $this->email)->first();
} elseif ($this->string == 'Teacher') {
$user = Teacher::where('email', $this->email)->first();
}
Mail::send('emails.reminder', ['user' => $user_request], function ($m) use($user) {
$m->from('asifrahmanarnab@gmail.com', 'Your Account');
$m->to($user->email, $user->name)->subject('Set up your account!');
});
}
示例13: submit_test
public function submit_test(Request $request, $event_slug, $round_no)
{
$json['errors'] = [];
$json['messages'] = [];
if (!Session::has('id')) {
$json['errors']['login'] = "Please login to Continue";
return response()->json($json);
}
$student = Student::where('id', Session::get('id'))->where('validated', true)->first();
$event = Event::where('slug', $event_slug)->where('verified', true)->first();
if (!$event) {
$json['errors']['event'] = "This event doesnot exist";
return response()->json($json);
}
$round = $event->rounds()->where('no', $round_no)->first();
if (!$round) {
$json['errors']['round'] = "This round doesnot exist";
return response()->json($json);
}
$qualifier = $round->qualifiers()->where('student_id', $student->id)->first();
if (!$qualifier) {
$json['errors']['round'] = "You are not qualified for this Round";
return response()->json($json);
}
$now = Carbon::now();
if ($now->gte(new Carbon($round->start_date_time)) && (new Carbon($round->start_date_time))->addHours($round->duration)->addMinutes(5)->gt($now)) {
$score = 0;
$i = 1;
$questions = $round->questions()->orderBy('no', 'asc')->get();
foreach ($questions as $question) {
if (isset($request->answers[$i]) && $request->answers[$i] == $question->answer) {
$score++;
}
$i++;
}
$qualifier->score = $score;
$qualifier->completion_time = $now;
$qualifier->save();
$json['message'] = "sucessfull";
return response()->json($json);
} else {
$json['errors']['round'] = "You can only finish round during the given time";
return response()->json($json);
}
}
示例14: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$course = Course::findOrFail($id);
if (\Auth::user()->role_id == 3) {
$is_professor = true;
$professor = DB::table('professors')->join('users', 'professors.user_id', '=', 'users.id')->where('users.id', '=', \Auth::user()->id)->first();
$lectures = DB::table('lectures')->where('course_id', '=', $id)->get();
return view('shared.course_detail', compact('course', 'is_professor', 'professor', 'course', 'lectures'));
}
if (\Auth::user()->role_id == 4) {
$courses = DB::table('courses')->join('institutions', 'institutions.id', '=', 'courses.inst_id')->join('professors', 'professors.prof_id', '=', 'courses.prof_id')->where('courses.id', '=', $id)->first();
$student_id = Student::where('user_id', '=', \Auth::user()->id)->first()->id;
$student_course = StudentCourses::where('student_id', '=', $student_id)->where('course_id', '=', $id)->first();
if ($student_course) {
$is_enrolled = true;
} else {
$is_enrolled = false;
}
$lectures = DB::table('lectures')->where('course_id', '=', $id)->get();
$is_student = true;
return view('course.view_one', compact('courses', 'is_student', 'is_enrolled', 'lectures'));
}
}
示例15: studentiPredmetaPdf
public function studentiPredmetaPdf()
{
$predmet = Input::get('predmet');
$program = Input::get('program');
$letnik = Input::get('letnik');
$leto = Input::get('leto');
$naslov = Input::get('naslov');
$stHidden[0] = $predmet;
$stHidden[1] = $program;
$stHidden[2] = $letnik;
$stHidden[3] = $leto;
$predmeti = Vpisan_predmet::where('sifra_predmeta', $predmet)->where('sifra_studijskega_programa', $program)->where('sifra_letnika', $letnik)->where('sifra_studijskega_leta', $leto)->get();
$studenti = [];
for ($i = 0; $i < count($predmeti); $i++) {
$vp = $predmeti[$i]->vpisna_stevilka;
$studenti[$i][0] = $vp;
$studenti[$i][1] = Student::where('vpisna_stevilka', $vp)->pluck('ime_studenta') . " " . Student::where('vpisna_stevilka', $vp)->pluck('priimek_studenta');
$studenti[$i][2] = Vrsta_vpisa::where('sifra_vrste_vpisa', Vpis::where('vpisna_stevilka', $vp)->where('sifra_studijskega_leta', $leto)->where('sifra_studijskega_programa', $program)->pluck('sifra_vrste_vpisa'))->pluck('opis_vrste_vpisa');
}
$pdf = PDF::loadView('studentipredmetaexport', ['students' => $studenti, 'naslov' => $naslov, 'stHidden' => $stHidden, 'izvoz' => 1]);
return $pdf->stream('seznamStudentov.pdf');
//return view('studentipredmeta', ['students' => $studenti, 'naslov' => $naslov[0], 'stHidden' => $stHidden]);
//return Redirect::back();
}