当前位置: 首页>>代码示例>>PHP>>正文


PHP Student::findOrFail方法代码示例

本文整理汇总了PHP中Student::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Student::findOrFail方法的具体用法?PHP Student::findOrFail怎么用?PHP Student::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Student的用法示例。


在下文中一共展示了Student::findOrFail方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  * Update the specified student in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $student = Student::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Student::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $student->update($data);
     return Redirect::route('students.index');
 }
开发者ID:blestab,项目名称:laravel-school-erp,代码行数:16,代码来源:StudentsController.php

示例2: getJson

 public function getJson($id)
 {
     $student = Student::findOrFail($id);
     $courses = $student->course;
     return Response::json($courses);
 }
开发者ID:andelus,项目名称:echooly,代码行数:6,代码来源:CourseController.php

示例3: foreach

    return 0;
}
$tutorials = Tutorials::all();
foreach ($tutorials as $tutorial) {
    if ($tutorial->published == 1) {
        if (Sentry::check()) {
            $usere = Sentry::getUser();
            $usergroup = $usere->getGroups();
            $usergroupe = json_decode($usergroup, true);
            $usergroupe[0]['pivot']['group_id'];
            $group = Sentry::findGroupById($usergroupe[0]['pivot']['group_id']);
            $groupname = $group->name;
            if ($groupname == 'teachers') {
                $user = Teacher::findOrFail($usere->id);
            } elseif ($groupname == 'students') {
                $user = Student::findOrFail($usere->id);
            } elseif ($groupname == 'admin') {
                $userw = Sentry::getUser();
                $user = Teacher::findOrFail($userw->id);
            }
            $ssubjects = $user->extra;
            $subjects = unserialize($ssubjects);
            $truth = 0;
            if ($subjects != null) {
                $truth = checkSubject($subjects, $tutorial->subjectid);
            }
            if ($truth == 0 && !Sentry::getUser()->inGroup(Sentry::findGroupByName('admin'))) {
                continue;
            }
        }
        $subject = Subject::find($tutorial->subjectid);
开发者ID:eufelipemartins,项目名称:edlara,代码行数:31,代码来源:tutorials.blade.php

示例4: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $flag = (bool) Input::get('flag');
     $student = Student::findOrFail($id);
     if ($flag) {
         // if student is approved
         $student->approved = 1;
     } else {
         // if student is rejected for some reason
         $student->rejected = 1;
     }
     $student->save();
     return "Student's approval/rejection status successfully changed.";
 }
开发者ID:linpar,项目名称:library-management-system,代码行数:20,代码来源:StudentController.php

示例5: submit

    public function submit()
    {
        $userid = Sentry::getUser()->id;
        $user = Sentry::getUser();
        $student = Student::findOrFail($user->id);
        $ssubjects = $student->extra;
        $subjects = unserialize($ssubjects);
        $truth = self::subjectValidator($user->id, $subjects, Input::get('subject'));
        if ($truth == 0) {
            return Redirect::to(URL::previous());
        }
        $messages = array('title.required' => 'The :attribute is Required.', 'related_tutorial.unique' => 'You have already submitted a Assessment for this tutorial. Please Update it.You can only submit a Assessment Per Tutorial', 'required' => 'The :attribute is Required');
        $validator = Validator::make(Input::all(), array('id' => 'required', 'title' => 'required|max:128|min:5', 'description' => 'max:1024', 'related_tutorial' => "required|unique:assessments,tutorialid,NULL,id,studentid," . $userid, 'submitted_to' => 'required', 'subject' => 'required', 'assessment_type' => 'required'), $messages);
        if ($validator->fails()) {
            Input::flash();
            return Redirect::to('/assessment/submit')->withErrors($validator);
        }
        $assessment = new Assessments();
        $assessment->title = Input::get('title');
        $assessment->description = Input::get('description');
        $assessment->assessmenttype = Input::get('assessment_type');
        $assessment->tutorialid = Input::get('related_tutorial');
        $assessment->teacherid = Input::get('submitted_to');
        $assessment->subjectid = Input::get('subject');
        $assessment->studentid = Sentry::getUser()->id;
        $assessment->save();
        $newassessment = DB::table('assessments')->orderby('id', 'desc')->first();
        $assessment = Assessments::find($newassessment->id);
        if (Input::hasFile('attachments')) {
            $files = Input::file('attachments');
            foreach ($files as $file) {
                if ($file) {
                    $name = $file->getClientOriginalName();
                    File::makeDirectory(app_path() . '/attachments/assessment-' . $newassessment->id . '/', 777);
                    $file->move(app_path() . '/attachments/assessment-' . $newassessment->id . '/', $name);
                }
            }
        }
        $data = array();
        $data['fname'] = User::find($assessment->studentid)->first_name;
        $data['lname'] = User::find($assessment->studentid)->last_name;
        $data['tutorial'] = Tutorials::find($assessment->tutorialid)->name;
        $data['submittedby'] = User::find($assessment->studentid)->first_name . ' ' . User::find($assessment->studentid)->last_name;
        $data['submittedon'] = $assessment->created_at;
        Mail::send('emails.assessmentsubmit', $data, function ($message) use($assessment) {
            $userid = $assessment->teacherid;
            $user = Sentry::findUserById($userid);
            $tutorial = Tutorials::find($assessment->tutorialid);
            $submittedby = User::find($assessment->studentid);
            $fullname = $user->first_name . ' ' . $user->last_name;
            $message->to($user->getLogin(), $fullname)->subject('New Assessment Submitted by ' . $submittedby->first_name . ' ' . $submittedby->last_name . ' on Tutorial ' . $tutorial->name);
        });
        // Input::file('attachment1')->move(app_path().'/attachments/assessment-'.$assessment->id.'/',$name);
        $theme = Theme::uses('site')->layout('default');
        $view = ['id' => $newassessment->id];
        $theme->asset()->container('datatables')->writeScript('inline-script', '$(document).ready(function(){
            $(\'#attachment\').dataTable({
                "sDom": "<\'row\'<\'col-xs-5 col-sm-5 col-md-5\'l><\'col-xs-5 col-sm-5 col-md-5\'f>r>t<\'row\'<\'col-xs-5 col-sm-5 col-md-5\'i><\'col-xs-5 col-sm-5 col-md-5\'p>>",
                "oLanguage": {
                    "sLengthMenu": "_MENU_ ' . ' Attachments per page"
                },
                "sPagination":"bootstrap"

            });
    });');
        return $theme->scope('assessment.update', $view)->render();
    }
开发者ID:eufelipemartins,项目名称:edlara,代码行数:67,代码来源:AssessmentController.php

示例6: dashboard

 /**
  * Display a listing of students
  *
  * @return Response
  */
 public function dashboard()
 {
     $data = Auth::Student()->get();
     $student = Student::findOrFail($data->id);
     return View::make('students.dashboard')->withStudent($student);
 }
开发者ID:andelus,项目名称:echooly,代码行数:11,代码来源:StudentController.php

示例7: manage

 public function manage($dash, $id, $mode)
 {
     switch ($mode) {
         case 'view':
             $theme = Theme::uses('dashboard')->layout('default');
             $view = array('name' => 'Dashboard User', 'id' => $id);
             $theme->breadcrumb()->add([['label' => 'Dashboard', 'url' => Setting::get('system.dashurl')], ['label' => 'Users', 'url' => Setting::get('system.dashurl') . '/users'], ['label' => $id, 'url' => Setting::get('system.dashurl') . '/user/1/view']]);
             $theme->setTitle(Setting::get('system.adminsitename') . ' User');
             $theme->setType('User');
             return $theme->scope('user.view', $view)->render();
             break;
         case 'edit':
             if (Sentry::getUser()->inGroup(Sentry::findGroupByName('admin'))) {
                 $theme = Theme::uses('dashboard')->layout('default');
                 $view = array('name' => 'Dashboard User', 'id' => $id);
                 $theme->breadcrumb()->add([['label' => 'Dashboard', 'url' => Setting::get('system.dashurl')], ['label' => 'Users', 'url' => Setting::get('system.dashurl') . '/users'], ['label' => $id, 'url' => Setting::get('system.dashurl') . '/user/1/edit']]);
                 $theme->setTitle(Setting::get('system.adminsitename') . ' User');
                 $theme->setType('User');
                 return $theme->scope('user.edit', $view)->render();
             } else {
                 return "NOT AUTHORISED";
             }
             break;
         case 'delete':
             $user = Sentry::getUser();
             // Find the Administrator group
             $admin = Sentry::findGroupByName('admin');
             // Check if the user is in the administrator group
             if ($user->inGroup($admin)) {
                 $deleteuser = Sentry::findUserById($id);
                 $usergroup = $deleteuser->getGroups();
                 $usergroupe = json_decode($usergroup, true);
                 $usergroupe[0]['pivot']['group_id'];
                 $group = Sentry::findGroupById($usergroupe[0]['pivot']['group_id']);
                 $groupname = $group->name;
                 if ($groupname == 'teachers') {
                     Teacher::findOrFail($id)->delete();
                 } elseif ($groupname == 'students') {
                     Student::findOrFail($id)->delete();
                 }
                 $deleteuser->delete();
                 return Redirect::to(URL::previous());
             } else {
                 return "UNAUTHORISED ACTION";
             }
             break;
         case 'suspend':
             $user = Sentry::getUser();
             // Find the Administrator group
             $admin = Sentry::findGroupByName('admin');
             // Check if the user is in the administrator group
             if ($user->inGroup($admin)) {
                 $throttle = Sentry::findThrottlerByUserId($id);
                 // Suspend the user
                 $throttle->suspend();
                 return Redirect::to(URL::previous());
             } else {
                 return "UNAUTHORISED ACTION";
             }
             break;
         case 'unsuspend':
             $throttle = Sentry::findThrottlerByUserId($id);
             // Suspend the user
             $throttle->unsuspend();
             return Redirect::to(URL::previous());
             break;
         case 'ban':
             $user = Sentry::getUser();
             // Find the Administrator group
             $admin = Sentry::findGroupByName('admin');
             // Check if the user is in the administrator group
             if ($user->inGroup($admin)) {
                 $throttle = Sentry::findThrottlerByUserId($id);
                 // Suspend the user
                 $throttle->ban();
                 return Redirect::to(URL::previous());
             } else {
                 return "UNAUTHORISED ACTION";
             }
             break;
         case 'unban':
             $throttle = Sentry::findThrottlerByUserId($id);
             // Suspend the user
             $throttle->unban();
             return Redirect::to(URL::previous());
             break;
     }
 }
开发者ID:eufelipemartins,项目名称:edlara,代码行数:88,代码来源:UserController.php


注:本文中的Student::findOrFail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。