当前位置: 首页>>代码示例>>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;未经允许,请勿转载。