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


PHP User::destroy方法代码示例

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


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

示例1: destroy

 /**
  * Delete a user.
  *
  * @param int $id
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function destroy($id)
 {
     if (!auth()->user()->is_admin || auth()->user()->id === $id) {
         abort(403);
     }
     return response()->json(User::destroy($id));
 }
开发者ID:vvdcect,项目名称:koel,代码行数:14,代码来源:UserController.php

示例2: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     if ($id == 1) {
         return redirect()->route('admin.user.index')->withErrors(array('Ошибка! Администратора системы удалить нельзя!'));
     }
     $this->users->destroy($id);
     return redirect()->route('admin.user.index');
 }
开发者ID:qubikr,项目名称:laravel,代码行数:15,代码来源:UserController.php

示例3: destroyUser

 public function destroyUser($id)
 {
     $authUser = Auth::user();
     $user = User::findOrFail($id);
     if ($user->id == $authUser->id) {
         return -1;
     }
     $result = User::destroy($id);
     return $result;
 }
开发者ID:jaumesala,项目名称:opendata-maps,代码行数:10,代码来源:UserRepository.php

示例4: destroy

 public function destroy($id)
 {
     $user_id = Auth::user()->id;
     $deleted_count = User::destroy($id);
     if ($deleted_count > 0) {
         Flash::success('Se ha borrado el usuario.');
     } else {
         Flash::error('Ocurrió un problema durante el borrado.');
     }
     return redirect($user_id != $id ? 'users' : '');
 }
开发者ID:alexpizarroj,项目名称:orange,代码行数:11,代码来源:UsersController.php

示例5: delete

 public function delete($id = 0)
 {
     if (is_array(Input::get('ids'))) {
         $id = Input::get('ids');
     }
     $ok = User::destroy($id);
     if ($ok) {
         return Redirect::to('msg')->withInput()->with('jump_sec', 3)->with('jump_url', URL::to('admin/user_list'))->with('message', "删除成功!");
     } else {
         return Redirect::to('msg')->withInput()->with('jump_sec', 3)->with('message', "删除失败!");
     }
 }
开发者ID:snyh,项目名称:just-calc-dstore-info,代码行数:12,代码来源:UserController.php

示例6: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     if ($result = check_auth_to('YHLB_DELETE')) {
         return $result;
     }
     try {
         User::destroy($id);
         return redirect()->action('Admin\\UserController@index')->with('operationstatus', 'sucess');
     } catch (\Exception $e) {
         return redirect()->back()->withErrors(['error' => '删除用户失败,请重试(' . $e->getMessage() . ')']);
     }
 }
开发者ID:xinzou,项目名称:authority_management,代码行数:18,代码来源:UserController.php

示例7: updateUser

 public function updateUser($parameters)
 {
     try {
         $userLogs = new UserLogsService();
         switch ($parameters['oper']) {
             case 'changePassword':
                 $id = $parameters['id'];
                 $user = User::find(reset($id));
                 $validator = $this->getUserValidator($parameters, true, false, true);
                 if ($validator->fails()) {
                     throw new \Exception($validator->messages());
                 }
                 $user->password = $this->hashPassword($parameters['password']);
                 $user->save();
                 $userLogs->createUserLog($parameters);
                 return true;
                 break;
             case 'generateApiKey':
                 $id = $parameters['ids'];
                 $user = User::find(reset($id));
                 Artisan::call('api-key:generate', array('--user-id' => $user->id));
                 $userLogs->createUserLog($parameters);
                 return true;
                 break;
             case 'del':
                 $userLogs->createUserLog($parameters);
                 return User::destroy($parameters['ids']);
                 break;
             case 'add':
                 $user = $this->newUser($parameters);
                 $userLogs->createUserLog($parameters);
                 break;
             case 'edit':
                 //                    DB::table('campaign')->insert(
                 //                        array('id' => '572', 'name' => 'squaretraffic2')
                 //                    );
                 $id = $parameters['id'];
                 $user = User::find($id);
                 $validator = $this->getUserValidator($parameters, true, $user->email !== $parameters['email']);
                 if ($validator->fails()) {
                     throw new \Exception($validator->messages());
                 }
                 $userLogs->createUserLog($parameters);
                 break;
         }
         $columns = array_intersect_key($parameters, array_flip($user->getFillableColumns()));
         if (!empty($columns)) {
             $user->update($columns);
         }
         $relationships = array_intersect_key($parameters, array_flip(User::$relationshipsAllowedToUpdate));
         if (!empty($relationships)) {
             foreach ($relationships as $relationshipType => $relationshipValue) {
                 if (!empty($relationshipValue)) {
                     if (!is_array($relationshipValue)) {
                         $relationshipValue = explode(',', $relationshipValue);
                     }
                     $user->{$relationshipType}()->sync($relationshipValue);
                 }
             }
         }
         return $user;
     } catch (\Exception $e) {
         throw $e;
     }
 }
开发者ID:jbs321,项目名称:affiliate-reporting-v1,代码行数:65,代码来源:UserService.php

示例8: getUserDelete

 public function getUserDelete($id)
 {
     User::destroy($id);
     return Redirect::to('admin')->with('message', 'Пользователь удален');
 }
开发者ID:RybinDen,项目名称:laravel-blog,代码行数:5,代码来源:AdminController.php

示例9: delete

 function delete($id)
 {
     User::destroy($id);
 }
开发者ID:thabung,项目名称:serveaseme,代码行数:4,代码来源:UsersDao.php

示例10: destroy

 public function destroy($id)
 {
     User::destroy($id);
     return ['deleted' => true];
 }
开发者ID:woakes070048,项目名称:laravel,代码行数:5,代码来源:UserController.php

示例11: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($id)
 {
     User::destroy($id);
     return back()->with('info', '删除成功~');
 }
开发者ID:q393250152,项目名称:my_shop,代码行数:11,代码来源:UserController.php

示例12: destroy

 /**
  * @param $id
  *
  * @return int
  */
 public function destroy($id)
 {
     return User::destroy($id);
 }
开发者ID:salvo1404,项目名称:jwt-authentication,代码行数:9,代码来源:UserRepository.php


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