當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Student::Orderby方法代碼示例

本文整理匯總了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');
     }
 }
開發者ID:ncs-jss,項目名稱:library,代碼行數:50,代碼來源:UserController.php


注:本文中的app\Student::Orderby方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。