當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Location::getErrors方法代碼示例

本文整理匯總了PHP中app\models\Location::getErrors方法的典型用法代碼示例。如果您正苦於以下問題:PHP Location::getErrors方法的具體用法?PHP Location::getErrors怎麽用?PHP Location::getErrors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\Location的用法示例。


在下文中一共展示了Location::getErrors方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: fire


//.........這裏部分代碼省略.........
         $this->comment('First Name: ' . $first_name);
         $this->comment('Last Name: ' . $last_name);
         $this->comment('Username: ' . $user_username);
         $this->comment('Email: ' . $user_email);
         $this->comment('Category Name: ' . $user_asset_category);
         $this->comment('Item: ' . $user_asset_name);
         $this->comment('Manufacturer ID: ' . $user_asset_mfgr);
         $this->comment('Model No: ' . $user_asset_modelno);
         $this->comment('Serial No: ' . $user_asset_serial);
         $this->comment('Asset Tag: ' . $user_asset_tag);
         $this->comment('Location: ' . $user_asset_location);
         $this->comment('Purchase Date: ' . $user_asset_purchase_date);
         $this->comment('Purchase Cost: ' . $user_asset_purchase_cost);
         $this->comment('Notes: ' . $user_asset_notes);
         $this->comment('Company Name: ' . $user_asset_company_name);
         $this->comment('------------- Action Summary ----------------');
         if ($user_username != '') {
             if ($user = User::MatchEmailOrUsername($user_username, $user_email)->whereNotNull('username')->first()) {
                 $this->comment('User ' . $user_username . ' already exists');
             } else {
                 $user = new \App\Models\User();
                 $password = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);
                 $user->first_name = $first_name;
                 $user->last_name = $last_name;
                 $user->username = $user_username;
                 $user->email = $user_email;
                 $user->permissions = '{user":1}';
                 $user->password = bcrypt($password);
                 $user->activated = 1;
                 if ($user->save()) {
                     $this->comment('User ' . $first_name . ' created');
                 } else {
                     $this->error('ERROR CREATING User ' . $first_name . ' ' . $last_name);
                     $this->error($user->getErrors());
                 }
             }
         } else {
             $user = new User();
         }
         // Check for the location match and create it if it doesn't exist
         if ($location = Location::where('name', e($user_asset_location))->first()) {
             $this->comment('Location ' . $user_asset_location . ' already exists');
         } else {
             $location = new Location();
             if ($user_asset_location != '') {
                 $location->name = e($user_asset_location);
                 $location->address = '';
                 $location->city = '';
                 $location->state = '';
                 $location->country = '';
                 $location->user_id = 1;
                 if (!$this->option('testrun') == 'true') {
                     if ($location->save()) {
                         $this->comment('Location ' . $user_asset_location . ' was created');
                     } else {
                         $this->error('Something went wrong! Location ' . $user_asset_location . ' was NOT created');
                         $this->error($location->getErrors());
                     }
                 } else {
                     $this->comment('Location ' . $user_asset_location . ' was (not) created - test run only');
                 }
             } else {
                 $this->comment('No location given, so none created.');
             }
         }
         if (e($user_asset_category) == '') {
開發者ID:dmeltzer,項目名稱:snipe-it,代碼行數:67,代碼來源:AssetImportCommand.php

示例2: postCreate

 /**
  * Validates and stores a new location.
  *
  * @todo Check if a Form Request would work better here.
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @see LocationsController::getCreate() method that makes the form
  * @since [v1.0]
  * @return Redirect
  */
 public function postCreate()
 {
     // create a new location instance
     $location = new Location();
     // Save the location data
     $location->name = e(Input::get('name'));
     if (Input::get('parent_id') == '') {
         $location->parent_id = null;
     } else {
         $location->parent_id = e(Input::get('parent_id'));
     }
     $location->currency = e(Input::get('currency', '$'));
     $location->address = e(Input::get('address'));
     $location->address2 = e(Input::get('address2'));
     $location->city = e(Input::get('city'));
     $location->state = e(Input::get('state'));
     $location->country = e(Input::get('country'));
     $location->zip = e(Input::get('zip'));
     $location->user_id = Auth::user()->id;
     if ($location->save()) {
         // Redirect to the new location  page
         return redirect()->to("admin/settings/locations")->with('success', trans('admin/locations/message.create.success'));
     }
     return redirect()->back()->withInput()->withErrors($location->getErrors());
 }
開發者ID:dmeltzer,項目名稱:snipe-it,代碼行數:34,代碼來源:LocationsController.php


注:本文中的app\models\Location::getErrors方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。