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


PHP Manufacturer::where方法代码示例

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


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

示例1: fire


//.........这里部分代码省略.........
             $user_email_array = User::generateFormattedNameFromFullName($this->option('email_format'), $user_name);
             $first_name = $user_email_array['first_name'];
             $last_name = $user_email_array['last_name'];
             if ($user_email == '') {
                 $user_email = $user_email_array['username'] . '@' . Config::get('app.domain');
             }
             if ($user_username == '') {
                 if ($this->option('username_format') == 'email') {
                     $user_username = $user_email;
                 } else {
                     $user_name_array = User::generateFormattedNameFromFullName($this->option('username_format'), $user_name);
                     $user_username = $user_name_array['username'];
                 }
             }
         }
         $this->comment('Full Name: ' . $user_name);
         $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 {
                 // Create the user
                 $user = Sentry::createUser(array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $user_email, 'username' => $user_username, 'password' => substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 12), 'activated' => true, 'permissions' => array('admin' => 0, 'user' => 1), 'notes' => 'User imported through asset importer'));
                 // Find the group using the group id
                 $userGroup = Sentry::findGroupById(3);
                 // Assign the group to the user
                 $user->addGroup($userGroup);
                 $this->comment('User ' . $first_name . ' created');
             }
         } 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->comment('Something went wrong! Location ' . $user_asset_location . ' was NOT created');
                     }
                 } else {
开发者ID:cralle,项目名称:snipe-it,代码行数:67,代码来源:AssetImportCommand.php

示例2: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $filename = $this->argument('filename');
     if (!$this->option('testrun') == 'true') {
         $this->comment('======= Importing ' . $filename . ' =========');
     } else {
         $this->comment('====== TEST ONLY Import for ' . $filename . ' ====');
         $this->comment('============== NO DATA WILL BE WRITTEN ==============');
     }
     if (!ini_get("auto_detect_line_endings")) {
         ini_set("auto_detect_line_endings", '1');
     }
     $csv = Reader::createFromPath($this->argument('filename'));
     $csv->setNewline("\r\n");
     $csv->setOffset(1);
     $duplicates = '';
     // Loop through the records
     $nbInsert = $csv->each(function ($row) use($duplicates) {
         $status_id = 1;
         if (is_numeric($row[0])) {
             $this->comment('User ' . $row[0] . ' is not a name - assume this user already exists');
         } elseif ($row[0] == '') {
             $this->comment('No user data provided - skipping user creation, just adding asset');
         } else {
             // Generate an email based on their name
             $name = explode(" ", $row[0]);
             $first_name = $name[0];
             $last_name = '';
             $email_last_name = '';
             if ($first_name == 'Unknown') {
                 $status_id = 7;
             }
             if (!array_key_exists(1, $name)) {
                 $last_name = '';
                 $email_last_name = $last_name;
                 $email_prefix = $first_name;
             } else {
                 // Loop through the rest of the explode so you don't truncate
                 for ($x = 0; $x < count($name); $x++) {
                     if ($x > 0 && $name[$x] != '') {
                         $last_name .= ' ' . $name[$x];
                         $email_last_name .= $name[$x];
                     }
                 }
                 $email_prefix = $first_name[0] . $email_last_name;
             }
             $email = strtolower(str_replace('.', '', $email_prefix)) . '@' . $this->option('domain');
             $email = str_replace("'", '', $email);
             $this->comment('Full Name: ' . $row[0]);
             $this->comment('First Name: ' . $first_name);
             $this->comment('Last Name: ' . $last_name);
             $this->comment('Email: ' . $email);
             $this->comment('Category Name: ' . $row[1]);
             $this->comment('Item: ' . $row[2]);
             $this->comment('Manufacturer ID: ' . $row[3]);
             $this->comment('Model No: ' . $row[4]);
             $this->comment('Serial No: ' . $row[5]);
             $this->comment('Asset Tag: ' . $row[6]);
             $this->comment('Location: ' . $row[7]);
         }
         $this->comment('------------- Action Summary ----------------');
         if (isset($email)) {
             if ($user = User::where('email', $email)->first()) {
                 $this->comment('User ' . $email . ' already exists');
             } else {
                 // Create the user
                 $user = Sentry::createUser(array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'password' => substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10), 'activated' => true, 'permissions' => array('admin' => 0, 'user' => 1), 'notes' => 'Imported user'));
                 // Find the group using the group id
                 $userGroup = Sentry::findGroupById(3);
                 // Assign the group to the user
                 $user->addGroup($userGroup);
                 $this->comment('User ' . $first_name . ' created');
             }
         } else {
             $user = new User();
         }
         // Check for the location match and create it if it doesn't exist
         if ($location = Location::where('name', $row[7])->first()) {
             $this->comment('Location ' . $row[7] . ' already exists');
         } else {
             $location = new Location();
             $location->name = e($row[7]);
             $location->address = '';
             $location->city = '';
             $location->state = '';
             $location->country = '';
             $location->user_id = 1;
             if (!$this->option('testrun') == 'true') {
                 if ($location->save()) {
                     $this->comment('Location ' . $row[7] . ' was created');
                 } else {
                     $this->comment('Something went wrong! Location ' . $row[1] . ' was NOT created');
                 }
             } else {
                 $this->comment('Location ' . $row[7] . ' was (not) created - test run only');
//.........这里部分代码省略.........
开发者ID:stackedcreative,项目名称:snipe-it,代码行数:101,代码来源:ImportCommand.php

示例3: fire


//.........这里部分代码省略.........
                     $email_prefix = $first_name[0] . $email_last_name;
                 } elseif ($this->option('email_format') == 'firstname.lastname') {
                     $email_last_name .= str_replace(' ', '', $last_name);
                     $email_prefix = $first_name . '.' . $email_last_name;
                 } elseif ($this->option('email_format') == 'firstname') {
                     $email_last_name .= str_replace(' ', '', $last_name);
                     $email_prefix = $first_name;
                 }
             }
             // Generate an email based on their name if no email address is given
             if ($user_email == '') {
                 if ($first_name == 'Unknown') {
                     $status_id = 7;
                 }
                 $email = strtolower($email_prefix) . '@' . $this->option('domain');
                 $user_email = str_replace("'", '', $email);
             }
         }
         $this->comment('Full Name: ' . $user_name);
         $this->comment('First Name: ' . $first_name);
         $this->comment('Last Name: ' . $last_name);
         $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('Notes: ' . $user_asset_notes);
         $this->comment('------------- Action Summary ----------------');
         if ($user_email != '') {
             if ($user = User::where('email', $user_email)->first()) {
                 $this->comment('User ' . $user_email . ' already exists');
             } else {
                 // Create the user
                 $user = Sentry::createUser(array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $user_email, 'password' => substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10), 'activated' => true, 'permissions' => array('admin' => 0, 'user' => 1), 'notes' => 'Imported user'));
                 // Find the group using the group id
                 $userGroup = Sentry::findGroupById(3);
                 // Assign the group to the user
                 $user->addGroup($userGroup);
                 $this->comment('User ' . $first_name . ' created');
             }
         } else {
             $user = new User();
         }
         // Check for the location match and create it if it doesn't exist
         if ($location = Location::where('name', $user_asset_location)->first()) {
             $this->comment('Location ' . $user_asset_location . ' already exists');
         } else {
             $location = new 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->comment('Something went wrong! Location ' . $user_asset_location . ' was NOT created');
                 }
             } else {
                 $this->comment('Location ' . $user_asset_location . ' was (not) created - test run only');
开发者ID:norganna,项目名称:snipe-it,代码行数:67,代码来源:ImportCommand.php


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