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


PHP Group::findOrFail方法代码示例

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


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

示例1: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     //$this->validate($request, ['name' => 'required']); // Uncomment and modify if needed.
     $group = Group::findOrFail($id);
     $group->update($request->all());
     return redirect('admin/groups')->with('success', Lang::get('message.success.update'));
 }
开发者ID:zangee3,项目名称:avs,代码行数:13,代码来源:GroupsController.php

示例2: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // we expect a url in the form /groups/{group_id}
     if ($request->segment(1) == 'groups') {
         if ($this->auth->guest()) {
             $group = \App\Group::findOrFail($request->segment(2));
             if ($group->isPublic()) {
                 return $next($request);
             } else {
                 return redirect()->back()->with('message', trans('messages.not_allowed'));
             }
         } else {
             $group = \App\Group::findOrFail($request->segment(2));
             if ($group->isPublic()) {
                 return $next($request);
             } elseif ($group->isMember()) {
                 return $next($request);
             } elseif ($request->user()->isAdmin()) {
                 return $next($request);
                 // user is admin, and sees everything, fine (at least in sync with current policies for admins)
             } else {
                 return redirect()->back()->with('message', trans('messages.not_allowed'));
             }
         }
     } else {
         return redirect()->back()->with('message', 'Are you in a group at all !? (url doesnt start with group/something). This is a bug');
     }
 }
开发者ID:philippejadin,项目名称:Mobilizator,代码行数:36,代码来源:RedirectIfNotGroupMemberOrPublicGroup.php

示例3: store

 public function store(Request $request)
 {
     $user = Auth::user();
     if ($user->is('admin|groupadmin')) {
         if ($request->hasFile('file')) {
             $filename = $request->file('file')->getClientOriginalName();
             if ($request->file('file')->move(sys_get_temp_dir(), $filename)) {
                 $path = sys_get_temp_dir() . '/' . $filename;
                 if ($request->has('user_id')) {
                     $target = User::findOrFail($request->input('user_id'));
                     $folder = $target->username;
                     $ret = redirect(url('admin/show/' . $target->id));
                 } else {
                     if ($request->has('group_id')) {
                         $group = Group::findOrFail($request->input('group_id'));
                         $folder = $group->name;
                         $ret = redirect(url('admin/groups/'));
                     }
                 }
                 if ($user->testAccess($folder)) {
                     Cloud::loadFile($path, $folder, $filename);
                 } else {
                     abort(403);
                 }
                 unlink($path);
             }
         }
         return $ret;
     } else {
         abort(403);
     }
 }
开发者ID:OfficineDigitali,项目名称:tiret,代码行数:32,代码来源:FileController.php

示例4: destroy

 public function destroy($groupId)
 {
     $group = Group::findOrFail($groupId);
     $this->authorize('destroy', $group);
     $group->delete();
     return Redirect::to(route('group.index'))->with(['success_message' => 'Deleted!']);
 }
开发者ID:nguyenvanduocit,项目名称:Password-Manager,代码行数:7,代码来源:GroupController.php

示例5: store

 /**
  * @param $id
  * @param \Illuminate\Http\Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function store($id, \Illuminate\Http\Request $request)
 {
     $this->validate($request, ['name' => 'required|max:255', 'factor' => 'required']);
     $group = Group::findOrFail($id);
     $subject = new Subject(Request::all());
     $group->subjects()->save($subject);
     return redirect('groups');
 }
开发者ID:severinkaderli,项目名称:gradus,代码行数:13,代码来源:SubjectController.php

示例6: remove

 public function remove($id, Request $request)
 {
     $group = Group::findOrFail($id);
     $user = User::findOrFail($request->input('userId'));
     $group->users()->detach($user);
     $group->save();
     return redirect()->back();
 }
开发者ID:partio-scout,项目名称:kokous_backend,代码行数:8,代码来源:GroupUserController.php

示例7: update

 public function update(GroupRequest $request, $id)
 {
     $group = \App\Group::findOrFail($id);
     $group->update($request->all());
     $group->swimmers()->sync($request->get('swimmer_list'));
     \Session::flash('flash_message', 'Group has been updated.');
     return redirect('groups');
 }
开发者ID:romulodl,项目名称:swim,代码行数:8,代码来源:GroupController.php

示例8: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $group = Group::findOrFail($id);
     if ($group) {
         $group->delete();
         return ['success' => true];
     }
     return ['success' => true];
 }
开发者ID:Orvo,项目名称:mlraamattu,代码行数:15,代码来源:GroupsController.php

示例9: destroy

 /**
  * Dissasociate the specified member resource from the group-event tuple.
  *
  * @param  int  $groupId
  * @param  int  $memberId
  * @return Response
  */
 public function destroy($groupId, $memeberId)
 {
     $group = Group::findOrFail($groupId);
     $member = $group->members()->findOrFail($memeberId);
     if (Gate::denies('detach-member', $event, $group, $member)) {
         abort(403);
     }
     $member->groups()->detach();
     return response()->json("ok");
 }
开发者ID:abada,项目名称:pleem,代码行数:17,代码来源:GroupMemberController.php

示例10: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     try {
         $group = Group::findOrFail($id);
         $group->delete();
         $msg = "Delete successful!";
     } catch (ModelNotFoundException $e) {
         $msg = "Cannot delete record. Data not found.";
         return redirect('group')->with('errMsg', $msg);
     }
     return redirect('group')->with('message', $msg);
 }
开发者ID:rayGobel,项目名称:sircular-dev,代码行数:18,代码来源:GroupController.php

示例11: letterSeach

 public function letterSeach($name)
 {
     $users = User::where('name', 'like', '%' . $name . '%')->paginate();
     foreach ($users as $u) {
         $u->user_type_id = User::$typeses[$u->user_type_id];
         if ($u->group_id == null) {
             $u->group_id = "No pertenece a un grupo";
         } else {
             $group = Group::findOrFail($u->group_id);
             $u->group_id = $group->name;
         }
     }
     return view('admin.users.index', compact('users'));
 }
开发者ID:averdugo,项目名称:serving,代码行数:14,代码来源:UsersController.php

示例12: addMany

 public function addMany(Request $request)
 {
     $group = Group::findOrFail($request->input('group'));
     $users = $group->users;
     $activity = Activity::findOrFail($request->input('activityId'));
     for ($i = 0; $i < count($users); $i++) {
         $user = $users[$i];
         $mark = $request->input($user->id);
         if ($mark != NULL && self::userHasCompletedActivity($user, $activity) == false) {
             $user->activities()->attach($activity, ['marked_by_user_id' => '1', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now(), 'event_date' => Carbon::now()]);
             $user->save();
         }
     }
     return redirect()->back();
 }
开发者ID:partio-scout,项目名称:kokous_backend,代码行数:15,代码来源:UserActivityController.php

示例13: store

    /**
     * Store a newly created resource in storage.
     *
     * @return Response
     */
    public function store(CreateUserRequest $request)
    {
        $token = str_random(40);
        $result = RegistrationLink::where('_token', $token)->first();
        while ($result != null) {
            $token = str_random(40);
            $result = RegistrationLink::where('_token', $token)->first();
        }
        $request['_token'] = $token;
        $request['valid_until'] .= ' 23:59:59';
        $group = Group::findOrFail($request->group_id);
        RegistrationLink::create($request->all());
        Session::flash('flash_message', 'New registration link for "' . $group->name . '" group member has been created!<br>
			Registration link is <a href="' . URL::to('admin/auth/register?_token=' . $request['_token']) . '">here</a>. You can send it to person you want to register as an administrator.');
        Session::flash('flash_secondary', 'true');
        Session::flash('flash_message_important', 'true');
        return redirect('/admin/user/create');
    }
开发者ID:ronal2do,项目名称:Laravel-CMS,代码行数:23,代码来源:UserController.php

示例14: saveGroupItem

 public function saveGroupItem()
 {
     if (Request::has('entity') && Request::has('block') && Request::has('id')) {
         $dataobj = Request::all();
         if ($dataobj['entity'] == 'groupitem') {
             try {
                 $groupitem = \App\Group::findOrFail($dataobj['id']);
                 $result = $groupitem->saveGroupItem($dataobj);
                 return ['status' => $result];
             } catch (Exception $exception) {
                 return ['status' => 'Что-то пошло не так. ' . $exception->getMessage()];
             }
         } else {
             return ['status' => 'Имя сохраняемой сущности не равно group (' . $dataobj['entity'] . ').'];
         }
     } else {
         return ['status' => 'Не хватает параметров для сохранения.'];
     }
 }
开发者ID:prehistorical,项目名称:floraclub,代码行数:19,代码来源:SaveAdminController.php

示例15: destroy

 /**
  * Remove the specified member from storage.
  *
  * @param  int  $id The id of the member to delete
  * @return Response
  */
 public function destroy($id)
 {
     // Find and delete group
     $group = Group::findOrFail($id);
     $group->delete();
     // Redirect
     Session::flash('message', 'Η κοινοβουλευτική ομάδα διαγράφηκε με επιτυχία!');
     return Redirect::to('groups');
 }
开发者ID:scify,项目名称:Vote-collector,代码行数:15,代码来源:GroupsController.php


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