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


PHP User::withTrashed方法代码示例

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


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

示例1: testDelete

 /**
  * Tests the update function in the UserController
  * @param  void
  * @return void
  */
 public function testDelete()
 {
     $this->call('POST', '/user', $this->userData);
     $this->call('DELETE', '/user/1/delete', $this->userData);
     $usersSaved = User::withTrashed()->find(1);
     $this->assertNotNull($usersSaved->deleted_at);
 }
开发者ID:echiteri,项目名称:iBLIS,代码行数:12,代码来源:UserControllerTest.php

示例2: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $cats = \App\Models\Category::lists('id');
     foreach (\App\Models\User::withTrashed()->get() as $user) {
         $user->categories = $cats;
         $user->save();
     }
 }
开发者ID:sirx,项目名称:w0bm.com,代码行数:13,代码来源:FilterSeeder.php

示例3: findOrThrowException

 /**
  * @param $id
  * @param bool $withRoles
  * @return mixed
  * @throws GeneralException
  */
 public function findOrThrowException($id, $withRoles = false)
 {
     if ($withRoles) {
         $user = User::with('roles')->withTrashed()->find($id);
     } else {
         $user = User::withTrashed()->find($id);
     }
     if (!is_null($user)) {
         return $user;
     }
     throw new GeneralException('That user does not exist.');
 }
开发者ID:qloog,项目名称:laravle5-lvyou,代码行数:18,代码来源:UserRepository.php

示例4: find

 /**
  * get user by id
  * @param            $id
  * @param bool|false $withRoles
  * @return array|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model|null
  */
 public function find($id, $withRoles = false)
 {
     if ($withRoles) {
         $user = User::with('roles')->withTrashed()->find($id);
     } else {
         $user = User::withTrashed()->find($id);
     }
     if (!is_null($user)) {
         return $user;
     }
     return array();
 }
开发者ID:aysenli,项目名称:laravel5-backend,代码行数:18,代码来源:UserRepository.php

示例5: setupCompleted

 public static function setupCompleted()
 {
     $users_table_exists = Schema::hasTable('users');
     $settings_table_exists = Schema::hasTable('settings');
     if ($users_table_exists && $settings_table_exists) {
         $usercount = User::withTrashed()->count();
         if ($usercount > 0) {
             return true;
         }
         return false;
     } else {
         return false;
     }
     return false;
 }
开发者ID:dmeltzer,项目名称:snipe-it,代码行数:15,代码来源:Setting.php

示例6: registerViaOAuth

 /**
  * @param SocialiteUser $oauthUserData
  * @param string        $provider
  *
  * @return Authenticatable|bool
  */
 public function registerViaOAuth(SocialiteUser $oauthUserData, $provider)
 {
     if (!($ownerAccount = User::withTrashed()->whereEmail($oauthUserData->email)->first())) {
         $ownerAccount = \Eloquent::unguarded(function () use($oauthUserData) {
             return User::create(['name' => $oauthUserData->name, 'email' => $oauthUserData->email, 'password' => \Hash::make(uniqid("", true))]);
         });
     }
     # If user account is soft-deleted, restore it.
     $ownerAccount->trashed() && $ownerAccount->restore();
     # Update missing user name.
     if (!$ownerAccount->name) {
         $ownerAccount->name = $oauthUserData->name;
         $ownerAccount->save();
     }
     # Event
     \Event::fire(new Registered($ownerAccount, $provider));
     ($doLinkOAuthAccount = $this->linkOAuthAccount($oauthUserData, $provider, $ownerAccount)) && $this->auth->login($ownerAccount, true);
     \Event::fire(new LoggedIn($ownerAccount, $provider));
     return $doLinkOAuthAccount;
 }
开发者ID:AudithSoftworks,项目名称:Basis-API,代码行数:26,代码来源:Registrar.php

示例7: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // Videos
     echo 'UPDATING VIDEOS', PHP_EOL, '===============', PHP_EOL;
     $count = 0;
     Video::withTrashed()->with('category')->chunk(200, function ($videos) use($count) {
         foreach ($videos as $v) {
             echo 'Updating Video with ID: ', $v->id, PHP_EOL;
             $v->detag();
             // quick and dirty. not 100% correct though.
             if ($v->category->shortname === 'pr0n') {
                 $v->tag('nsfw');
             } else {
                 $v->tag('sfw');
             }
             $v->tag(array_filter([$v->category->shortname, $v->category->name, $v->interpret, $v->songtitle, $v->imgsource], function ($elem) {
                 return !empty(trim($elem));
             }));
             $count++;
         }
     });
     echo PHP_EOL, PHP_EOL, 'Updated ', $count, ' Videos.', PHP_EOL, PHP_EOL, PHP_EOL;
     // User filters
     echo 'UPDATING USERS', PHP_EOL, '==============', PHP_EOL;
     $count = 0;
     $categories = Category::withTrashed()->get()->keyBy('id');
     User::withTrashed()->chunk(200, function ($users) use(&$count, $categories) {
         foreach ($users as $u) {
             echo 'Updating User: ', $u->username, PHP_EOL;
             $u->categories = array_values($categories->filter(function ($cat) use($u) {
                 return !in_array($cat->id, $u->categories);
             })->map(function ($cat) {
                 return $cat->shortname;
             })->all());
             $u->save();
             $count++;
         }
     });
     echo PHP_EOL, PHP_EOL, 'Updated ', $count, ' Users.', PHP_EOL, PHP_EOL, PHP_EOL;
 }
开发者ID:sirx,项目名称:w0bm.com,代码行数:45,代码来源:AddTags.php

示例8: checkEmail

 /**
  * @return string
  */
 public function checkEmail()
 {
     $email = User::withTrashed()->where('email', '=', Input::get('email'))->where('id', '<>', Auth::user()->id)->first();
     if ($email) {
         return 'taken';
     } else {
         return 'available';
     }
 }
开发者ID:rafaelsisweb,项目名称:invoice-ninja,代码行数:12,代码来源:AccountController.php

示例9: save

 /**
  * Stores new account
  *
  */
 public function save($userPublicId = false)
 {
     if (Auth::user()->account->isPro()) {
         $rules = ['first_name' => 'required', 'last_name' => 'required'];
         if ($userPublicId) {
             $user = User::where('account_id', '=', Auth::user()->account_id)->where('public_id', '=', $userPublicId)->firstOrFail();
             $rules['email'] = 'required|email|unique:users,email,' . $user->id . ',id';
         } else {
             $rules['email'] = 'required|email|unique:users';
         }
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             return Redirect::to($userPublicId ? 'users/edit' : 'users/create')->withInput()->withErrors($validator);
         }
         if ($userPublicId) {
             $user->first_name = trim(Input::get('first_name'));
             $user->last_name = trim(Input::get('last_name'));
             $user->username = trim(Input::get('email'));
             $user->email = trim(Input::get('email'));
         } else {
             $lastUser = User::withTrashed()->where('account_id', '=', Auth::user()->account_id)->orderBy('public_id', 'DESC')->first();
             $user = new User();
             $user->account_id = Auth::user()->account_id;
             $user->first_name = trim(Input::get('first_name'));
             $user->last_name = trim(Input::get('last_name'));
             $user->username = trim(Input::get('email'));
             $user->email = trim(Input::get('email'));
             $user->registered = true;
             $user->password = str_random(RANDOM_KEY_LENGTH);
             $user->confirmation_code = str_random(RANDOM_KEY_LENGTH);
             $user->public_id = $lastUser->public_id + 1;
         }
         $user->save();
         if (!$user->confirmed) {
             $this->userMailer->sendConfirmation($user, Auth::user());
             $message = trans('texts.sent_invite');
         } else {
             $message = trans('texts.updated_user');
         }
         Session::flash('message', $message);
     }
     return Redirect::to('company/advanced_settings/user_management');
 }
开发者ID:GhDj,项目名称:erp-fac-fin,代码行数:47,代码来源:UserController.php

示例10: getClone

 /**
  * Return a view containing a pre-populated new user form,
  * populated with some fields from an existing user.
  *
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @since [v1.0]
  * @param  int  $id
  * @return Redirect
  */
 public function getClone($id = null)
 {
     // We need to reverse the UI specific logic for our
     // permissions here before we update the user.
     $permissions = Input::get('permissions', array());
     //$this->decodePermissions($permissions);
     app('request')->request->set('permissions', $permissions);
     try {
         // Get the user information
         $user_to_clone = User::withTrashed()->find($id);
         $user = clone $user_to_clone;
         $user->first_name = '';
         $user->last_name = '';
         $user->email = substr($user->email, ($pos = strpos($user->email, '@')) !== false ? $pos : 0);
         $user->id = null;
         // Get this user groups
         $userGroups = $user_to_clone->groups()->lists('name', 'id');
         // Get a list of all the available groups
         $groups = Group::pluck('name', 'id');
         // Get all the available permissions
         $permissions = config('permissions');
         $clonedPermissions = $user_to_clone->decodePermissions();
         $userPermissions = Helper::selectedPermissionsArray($permissions, $clonedPermissions);
         //$this->encodeAllPermissions($permissions);
         $location_list = Helper::locationsList();
         $company_list = Helper::companyList();
         $manager_list = Helper::managerList();
         // Show the page
         return View::make('users/edit', compact('groups', 'userGroups', 'permissions', 'userPermissions'))->with('location_list', $location_list)->with('company_list', $company_list)->with('manager_list', $manager_list)->with('user', $user)->with('groups', $groups)->with('userGroups', $userGroups)->with('clone_user', $user_to_clone);
     } catch (UserNotFoundException $e) {
         // Prepare the error message
         $error = trans('admin/users/message.user_not_found', compact('id'));
         // Redirect to the user management page
         return redirect()->route('users')->with('error', $error);
     }
 }
开发者ID:stijni,项目名称:snipe-it,代码行数:45,代码来源:UsersController.php

示例11: registerViaOAuth

 /**
  * @param SocialiteUser $oauthUserData
  * @param string        $provider
  *
  * @return \Illuminate\Contracts\Auth\Authenticatable|bool
  */
 protected function registerViaOAuth(SocialiteUser $oauthUserData, $provider)
 {
     /** @var \App\Models\User $ownerAccount */
     if (!($ownerAccount = User::withTrashed()->whereEmail($oauthUserData->email)->first())) {
         $ownerAccount = User::create(['name' => $oauthUserData->name, 'email' => $oauthUserData->email, 'password' => app('hash')->make(uniqid("", true))]);
         event(new Registered($ownerAccount, $provider));
     }
     # If user account is soft-deleted, restore it.
     $ownerAccount->trashed() && $ownerAccount->restore();
     # Update missing user name.
     if (!$ownerAccount->name) {
         $ownerAccount->name = $oauthUserData->name;
         $ownerAccount->save();
     }
     ($doLinkOAuthAccount = $this->linkOAuthAccount($oauthUserData, $provider, $ownerAccount)) && app('auth.driver')->login($ownerAccount, true);
     event(new LoggedIn($ownerAccount, $provider));
     return $doLinkOAuthAccount;
 }
开发者ID:audithsoftworks,项目名称:basis,代码行数:24,代码来源:LoginController.php

示例12: getComprobarusername

 public function getComprobarusername($username)
 {
     $users = User::withTrashed()->where('username', '=', $username)->get();
     if (count($users) > 0) {
         return [array('existe' => true)];
     } else {
         return [array('existe' => false)];
     }
 }
开发者ID:bluesky777,项目名称:5myvc,代码行数:9,代码来源:PerfilesController.php


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