本文整理汇总了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');
}
}