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


PHP Member::findOrFail方法代码示例

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


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

示例1: getDeleteEquipe

 public function getDeleteEquipe($id)
 {
     $membro = Member::findOrFail($id);
     $membro->delete();
     $equipe = Member::all()->sortBy("name");
     return redirect('/editar_equipe')->with('equipe', $equipe);
 }
开发者ID:pablodarocha,项目名称:ejcm-flavio,代码行数:7,代码来源:AdminController.php

示例2: update

 public function update(Request $request, $id)
 {
     $member = \App\Member::findOrFail($id);
     $member->name = $request->name;
     $member->save();
     return redirect('/');
 }
开发者ID:dianahanly,项目名称:laravel-simple-CRUD,代码行数:7,代码来源:MemberController.php

示例3: handleProviderCallback

 /**
  * Obtain the user information from GitHub.
  *
  * @return Response
  */
 public function handleProviderCallback(Request $request)
 {
     // Used for development purposes. Hit /auth/google/callback
     // to get a dummy JWT for local use.
     if (\App::environment('local')) {
         $member = Member::findOrFail(1);
         if (!$member->hasRole('member')) {
             $member->attachRole(Role::where('name', 'member')->firstOrFail());
         }
         $token = JWTAuth::fromUser($member, ['level' => config('auth.levels.high'), 'member' => $member]);
         return response()->json($token);
     }
     $provider = new GoogleRitProvider($request);
     $user = $provider->user();
     if (array_get($user->user, 'domain', '') != 'g.rit.edu') {
         return new JsonResponse(['error' => 'domain user not authorized'], Response::HTTP_FORBIDDEN);
     }
     $member = Member::firstOrNew(['email' => $user->email]);
     $member->first_name = $user->user['name']['givenName'];
     $member->last_name = $user->user['name']['familyName'];
     $member->save();
     if (!$member->hasRole('member')) {
         $member->attachRole(Role::where('name', 'member')->firstOrFail());
     }
     $token = JWTAuth::fromUser($member, ['level' => config('auth.levels.high'), 'member' => $member]);
     if ($callback = $provider->getCallback()) {
         return redirect($callback . '?token=' . $token);
     } else {
         return response()->json(['token' => $token]);
     }
 }
开发者ID:rit-sse,项目名称:api,代码行数:36,代码来源:AuthController.php

示例4: byId

 public function byId($id)
 {
     try {
         $this->member = Member::findOrFail($id);
         return true;
     } catch (ModelNotFoundException $e) {
         return false;
     }
 }
开发者ID:rit-sse,项目名称:api,代码行数:9,代码来源:MemberAuthProvider.php

示例5: update

 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $member = Member::findOrFail($id);
     // TODO handle exception
     $member->first_name = $request->input('first_name', $member->first_name);
     $member->last_name = $request->input('last_name', $member->last_name);
     $member->save();
     return response()->json($member);
 }
开发者ID:kocsenc,项目名称:api,代码行数:16,代码来源:MemberController.php

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $admin = Role::firstOrCreate(['name' => 'admin', 'display_name' => 'Administrator', 'description' => 'Member is an administrator']);
     $member = Role::firstOrCreate(['name' => 'member', 'display_name' => 'Member', 'description' => 'Generic membership role']);
     $mentor = Role::firstOrCreate(['name' => 'mentor', 'display_name' => 'Mentor', 'description' => 'Member is a mentor']);
     $officer = Role::firstOrCreate(['name' => 'officer', 'display_name' => 'Officer', 'description' => 'Member is an officer']);
     if (\App::environment('local')) {
         $member = Member::findOrFail(1);
         $member->attachRole($admin);
     }
 }
开发者ID:rit-sse,项目名称:api,代码行数:16,代码来源:RolesTableSeeder.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @Response(201)
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['member_id' => 'required|exists:members,id', 'reason' => 'required', 'term_id' => 'required|exists:terms,id']);
     $member = Member::findOrFail($request->input('member_id'));
     $term = Term::findOrFail($request->input('term_id'));
     $membership = new Membership();
     $membership->reason = $request->input('reason');
     $membership->term_id = $request->input('term_id');
     $member->memberships()->save($membership);
     return new JsonResponse($membership, Response::HTTP_CREATED);
 }
开发者ID:rit-sse,项目名称:api,代码行数:18,代码来源:MembershipController.php

示例8: update

 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['first_name' => 'string', 'last_name' => 'string']);
     try {
         $member = Member::findOrFail($id);
         $member->first_name = $request->input('first_name', $member->first_name);
         $member->last_name = $request->input('last_name', $member->last_name);
         $member->save();
         return response()->json($member);
     } catch (ModelNotFoundException $e) {
         return new JsonResponse(['error' => 'not found'], Response::HTTP_NOT_FOUND);
     }
 }
开发者ID:rit-sse,项目名称:api,代码行数:20,代码来源:MemberController.php

示例9: store

 public function store(Request $request, $memberId)
 {
     // Upload a chunk, then
     // check if all chunks are done. If so
     // save the chunk to the database
     $config = new \Flow\Config();
     $config->setTempDir($this->tmpDir);
     $file = new \Flow\FileReadable($config);
     if ($file->validateChunk()) {
         $file->saveChunk();
     } else {
         // error, invalid chunk upload request, retry
         return response('', Response::HTTP_BAD_REQUEST);
         // 400
     }
     // Check for completion
     if ($file->validateFile()) {
         $blob = $file->saveToStream();
         $mimeType = $this->parseImageMimeType(strrchr($file->name(), '.'));
         if (!$mimeType) {
             // Not going to save if we don't know the mime type
             return response('Cannot determine image mime type from filename: ' . $file->name(), Response::HTTP_UNSUPPORTED_MEDIA_TYPE);
             // 415
         }
         // // If we wanted to ensure a 1-to-1 mapping for Member record and MemberPicture
         // MemberPicture::updateOrCreate(['regt_num' => $memberId], [
         // 'photo_blob' => $blob,
         // 'file_size' => $file->size(),
         // 'mime_type' => $mimeType
         // ]);
         $mp = new MemberPicture();
         // $mp->regt_num = $memberId;
         $mp->photo_blob = $blob;
         $mp->file_name = $file->name();
         $mp->file_size = $file->size();
         $mp->mime_type = $mimeType;
         $member = Member::findOrFail($memberId);
         $member->pictures()->save($mp);
         return response('Upload OK', Response::HTTP_CREATED);
         // 201
     }
     return response('', Response::HTTP_ACCEPTED);
     // 202
 }
开发者ID:alansfyeung,项目名称:FLARES,代码行数:44,代码来源:MemberPictureController.php

示例10: destroy

 /**
  * Remove the specified resource from storage.
  * Defaults to a soft delete; add ?remove=permanent to do hard delete
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Request $request, $id)
 {
     // remove -- [ discharge | permanent ]
     $removeMode = $request->query('remove', 'discharge');
     $deleted = 0;
     try {
         if ($removeMode == 'permanent') {
             $deletionMember = Member::where('regt_num', $id)->withTrashed()->firstOrFail();
             // Todo: future permissions check
             $permissionsCheck = true;
             if ($permissionsCheck || $deletionMember->is_active == '0') {
                 // Allow anybody to delete inactive records
                 $deletionMember->postings()->forceDelete();
                 $deletionMember->forceDelete();
                 // this returns void
                 $deleted = true;
                 // we just presume it worked, since we deleted the postings already
             } else {
                 throw new \Exception('You don\'t have permission to permanently delete this record', ResponseCodes::ERR_PERM_NOPE);
             }
         } else {
             // Soft delete -- read overrides from context
             $deleted = Member::findOrFail($id)->delete();
         }
         return response()->json(['success' => $deleted, 'deletionMode' => $removeMode]);
     } catch (\Exception $ex) {
         if (!$deleted) {
             return response()->json(['error' => ['code' => ResponseCodes::ERR_DELETION, 'deletionResult' => print_r($deleted, true), 'reason' => "Could not delete this record {$id}"]], 401);
         } else {
             return response()->json(['error' => ['code' => $ex->getCode(), 'reason' => $ex->getMessage()]], 403);
         }
     }
 }
开发者ID:alansfyeung,项目名称:FLARES,代码行数:40,代码来源:MemberController.php

示例11: changeOrder

 /**
  * Get new order of members from post data and save it to database
  *
  * @return mixed
  */
 public function changeOrder()
 {
     // Get id/order pairs
     $newOrders = Input::get('data');
     // Change each member's order to the new one
     foreach ($newOrders as $newOrder) {
         $member = Member::findOrFail($newOrder['id']);
         $member->order = $newOrder['order'];
         $member->save();
     }
     // Return success json
     return Response::json('success', 200);
 }
开发者ID:scify,项目名称:Vote-collector,代码行数:18,代码来源:MembersController.php

示例12: uploadCV

 /**
  * Upload the user's CV
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function uploadCV(Request $request, $id)
 {
     $member = Member::findOrFail($id);
     if (Gate::denies('upload-cv', $member)) {
         abort(403);
     }
     $this->validate($request, ['cv' => 'required|mimes:pdf']);
     // Handle cv PDF
     if ($request->file('cv')->isValid()) {
         $request->file('cv')->move(storage_path('app/cvs'), $id . '.pdf');
         return response()->json("ok");
     } else {
         abort(400);
     }
 }
开发者ID:abada,项目名称:pleem,代码行数:22,代码来源:MemberController.php


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