本文整理匯總了PHP中app\Student::Orderby方法的典型用法代碼示例。如果您正苦於以下問題:PHP Student::Orderby方法的具體用法?PHP Student::Orderby怎麽用?PHP Student::Orderby使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Student
的用法示例。
在下文中一共展示了Student::Orderby方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: postAddBook
public function postAddBook()
{
if (\Auth::check()) {
$data = Input::all();
array_pop($data);
$rules = ['book_id' => 'required', 'book_name' => 'required', 'book_desc' => 'required', 'mail' => 'required'];
$validator = Validator::make($data, $rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator->errors())->withInput();
} else {
$arrival = new Arrivals();
$arrival->book_id = $data['book_id'];
$arrival->book_name = $data['book_name'];
$arrival->book_desc = $data['book_desc'];
$arrival->save();
if ($data['mail'] == 0) {
$staffs = Staff::Orderby('id', 'des')->get();
foreach ($staffs as $staff) {
Mail::send('mail.mail', array('name' => $staff->name, 'book_name' => $data['book_name']), function ($message) use($staff) {
$message->to($staff->email, $staff->name)->subject('Library Notification');
});
}
} elseif ($data['mail'] == 1) {
$students = Student::Orderby('id', 'des')->get();
foreach ($students as $student) {
Mail::send('mail.mail', array('name' => $student->name, 'book_name' => $data['book_name']), function ($message) use($student) {
$message->to($student->email, $student->name)->subject('Library Notification');
});
}
} else {
$staffs = Staff::Orderby('id', 'des')->get();
foreach ($staffs as $staff) {
Mail::send('mail.mail', array('name' => $staff->name, 'book_name' => $data['book_name']), function ($message) use($staff) {
$message->to($staff->email, $staff->name)->subject('Library Notification');
});
}
$students = Student::Orderby('id', 'des')->get();
foreach ($students as $student) {
Mail::send('mail.mail', array('name' => $student->name, 'book_name' => $data['book_name']), function ($message) use($student) {
$message->to($student->email, $student->name)->subject('Library Notification');
});
}
}
Session::flash('err', "1");
return redirect('add_books');
}
} else {
return redirect('login');
}
}