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


PHP Teacher::findOrFail方法代码示例

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


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

示例1: foreach

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);
        $teacher = Teacher::find($tutorial->createdby);
        $username = Sentry::findUserByLogin($teacher->email);
        echo "<tr>";
开发者ID:eufelipemartins,项目名称:edlara,代码行数:31,代码来源:tutorials.blade.php

示例2: dashboard

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

示例3: createtutorial

 private function createtutorial($dash)
 {
     $user = Sentry::getUser();
     $userid = Sentry::getUser()->id;
     $teacher = Teacher::findOrFail($user->id);
     $ssubjects = $teacher->extra;
     $subjects = unserialize($ssubjects);
     $truth = self::subjectValidator($user->id, $subjects, Input::get('subject'));
     if ($truth == 0) {
         if (!Sentry::getUser()->inGroup(Sentry::findGroupByName('admin'))) {
             return Redirect::to(URL::previous());
         }
     }
     $tutorial = new Tutorials();
     $tutorial->name = Input::get('title');
     $tutorial->description = Input::get('description');
     $tutorial->content = Input::get('tutorial');
     $tutorial->createdby = Sentry::getUser()->id;
     $tutorial->subjectid = Input::get('subject');
     if (Input::get('published') == 'on') {
         $tutorial->published = 1;
     } else {
         $tutorial->published = 0;
     }
     $tutorial->save();
     $newtutorial = DB::table('tutorials')->orderby('id', 'desc')->first();
     if (Input::hasFile('attachments')) {
         $files = Input::file('attachments');
         foreach ($files as $file) {
             if ($file) {
                 $name = $file->getClientOriginalName();
                 $file->move(app_path() . '/attachments/tutorial-' . $newtutorial->id . '/', $name);
             }
         }
     }
     $newid = $newtutorial->id;
     Cache::forget("tutorial_listing_dash");
     return $newid;
 }
开发者ID:eufelipemartins,项目名称:edlara,代码行数:39,代码来源:TutorialsController.php

示例4: 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


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