public function getDefaultStateOptions() { $states = State::all(); foreach ($states as $state) { $stateOptions[$state->id] = $state->name; } return $stateOptions; }
public function getStateOptions() { return State::getNameList($this->country_id); }
/** * Returns rate information for a given location, optionally ignoring by priority. * @param array $locationInfo * @param array $ignoredPriorities * @return object */ protected function getRate($locationInfo, $ignoredPriorities = []) { $country = Country::find($locationInfo->country_id); if (!$country) { return null; } $state = null; if (strlen($locationInfo->state_id)) { $state = State::find($locationInfo->state_id); } $countryCode = $country->code; $stateCode = $state ? mb_strtoupper($state->code) : '*'; $zipCode = str_replace(' ', '', trim(strtoupper($locationInfo->zip))); if (!strlen($zipCode)) { $zipCode = '*'; } $city = str_replace('-', '', str_replace(' ', '', trim(mb_strtoupper($locationInfo->city)))); if (!strlen($city)) { $city = '*'; } $rate = null; foreach ($this->rates as $row) { $taxPriority = isset($row['priority']) ? $row['priority'] : 1; if (in_array($taxPriority, $ignoredPriorities)) { continue; } if ($row['country'] != $countryCode && $row['country'] != '*') { continue; } if (mb_strtoupper($row['state']) != $stateCode && $row['state'] != '*') { continue; } $rowZip = isset($row['zip']) && strlen($row['zip']) ? str_replace(' ', '', $row['zip']) : '*'; if ($rowZip != $zipCode && $rowZip != '*') { continue; } $rowCity = isset($row['city']) && strlen($row['city']) ? str_replace('-', '', str_replace(' ', '', mb_strtoupper($row['city']))) : '*'; if ($rowCity != $city && $rowCity != '*') { continue; } $compound = isset($row['compound']) ? $row['compound'] : 0; if (preg_match('/^[0-9]+$/', $compound)) { $compound = (int) $compound; } else { $compound = $compound == 'Y' || $compound == 'YES'; } $rateObj = ['rate' => $row['rate'], 'priority' => $taxPriority, 'name' => isset($row['tax_name']) ? $row['tax_name'] : 'TAX', 'compound' => $compound]; $rate = (object) $rateObj; break; } return $rate; }
$activityLog = new ActivityLog(); $types = $activityLog->actionTypes; $rand = rand(0, count($types) - 1); return $types[$rand]; }, 'message' => 'text', 'object_type' => 'optional:randomLetter|3', 'object_id' => 'optional:randomDigit', 'points_earned' => 'randomNumber', 'total_points' => 'randomNumber', 'timestamp' => 'dateTime|now', 'timezone' => 'timezone']); FactoryMuffin::define('DMA\\Friends\\Models\\Badge', ['title' => 'sentence', 'description' => 'optional:text', 'image' => 'optional:imageUrl|400;600', 'excerpt' => 'optional:text', 'congratulations_text' => 'optional:text', 'points' => 'randomNumber|3', 'maximum_earnings' => 'randomNumber|3', 'steps' => 'factory|DMA\\Friends\\Models\\Step', 'is_sequential' => 'boolean', 'show_earners' => 'boolean', 'time_between_steps_min' => 'randomDigitNotNull|8', 'time_between_steps_max' => 'randomDigitNotNull|8', 'maximium_time' => 'randomDigitNotNull|2', 'date_begin' => 'optional:dateTime', 'date_end' => 'optional:dateTime', 'is_published' => 'boolean', 'is_archived' => 'boolean', 'created_at' => 'dateTime|now', 'categories' => 'factory|DMA\\Friends\\Models\\Category']); FactoryMuffin::define('DMA\\Friends\\Models\\Category', ['name' => 'word', 'description' => 'optional:text', 'slug' => function ($object, $saved) { return Str::slug($object->title); }]); FactoryMuffin::define('DMA\\Friends\\Models\\Location', ['title' => 'word', 'description' => 'optional:text', 'created_at' => 'dateTime|now']); FactoryMuffin::define('DMA\\Friends\\Models\\Reward', ['title' => 'sentence', 'description' => 'optional:text', 'excerpt' => 'optional:text', 'fine_print' => 'optional:text', 'points' => 'randomDigitNotNull', 'image' => 'optional:imageUrl|400;600', 'barcode' => 'randomLetter|3', 'date_begin' => 'optional:dateTime', 'date_end' => 'optional:dateTime', 'days_valid' => 'optional:randomDigit|2', 'inventory' => 'optional:randomDigit|3', 'enable_email' => 'boolean', 'redemption_email' => 'optional:text', 'is_published' => 'boolean', 'is_archived' => 'boolean', 'hidden' => 'boolean', 'created_at' => 'dateTime|now']); FactoryMuffin::define('DMA\\Friends\\Models\\Step', ['title' => 'sentence', 'created_at' => 'dateTime|now', 'updated_at' => 'dateTime|now']); FactoryMuffin::define('RainLab\\User\\Models\\User', ['name' => 'userName', 'username' => 'userName', 'email' => 'email', 'password' => 'password', 'password_confirmation' => 'password', 'is_activated' => 'boolean', 'activated_at' => 'dateTime', 'last_login' => 'dateTime', 'country' => function ($object, $saved) { return Country::orderByRaw('RAND()')->first(); }, 'state' => function ($object, $saved) { return State::orderByRaw('RAND()')->first(); }, 'created_at' => 'dateTime|now', 'updated_at' => 'dateTime|now', 'phone' => 'optional:phone', 'company' => 'optional:company', 'street_addr' => 'streetAddress', 'city' => 'city', 'zip' => 'postcode', 'points' => 'randomNumber']); FactoryMuffin::define('DMA\\Friends\\Models\\Usermeta', ['first_name' => 'firstName', 'last_name' => 'lastName', 'email_optin' => 'boolean', 'current_member' => 'boolean', 'current_member_number' => 'randomNumber']); /** * Create and empty group * @var DMA\Friends\Models\UserGroup */ FactoryMuffin::define('DMA\\Friends\\Models\\UserGroup', ['owner_id' => 'factory|RainLab\\User\\Models\\User', 'is_active' => 'boolean|100']); /** * Create a group with the maxium of members allow in a group. * The limit is set in the settings of the plugin * @var DMA\Friends\Models\UserGroup */ FactoryMuffin::define('filled:DMA\\Friends\\Models\\UserGroup', [], function ($object) { $limit = Settings::get('maximum_users_per_group'); $members = FactoryMuffin::seed($limit, 'RainLab\\User\\Models\\User');
/** * @return array * Return all demographic options */ public static function getOptions() { $states = State::where('country_id', '=', 1)->get(); return ['gender' => self::$genderOptions, 'states' => $states, 'race' => self::$raceOptions, 'household_income' => self::$householdIncomeOptions, 'education' => self::$educationOptions]; }
public function getDefaultStateOptions() { return State::getNameList($this->default_country); }
/** * Updates and save the metadata for a user object */ public function updateMetadata(OctoberUser $user, $wordpressId) { $metadata = $this->db->table('wp_usermeta')->where('user_id', $wordpressId)->get(); // Organize the metadata for mapping to user fields $data = ['phone' => '', 'street_address' => '', 'city' => '', 'state' => '', 'zip' => '', 'first_name' => '', 'last_name' => '', '_badgeos_points' => '', 'email_optin' => false, 'current_member' => false, 'current_member_number' => '']; foreach ($metadata as $mdata) { $data[$mdata->meta_key] = $mdata->meta_value; } $user->phone = $data['phone']; $user->street_addr = $data['street_address']; $user->city = $data['city']; $user->zip = $data['zip']; $user->points = $data['_badgeos_points']; // Ensures that we have a barcode id for the user if (empty($user->barcode_id)) { $user->barcode_id = $user->name; } // Populate state and country objects if (!empty($data['state'])) { $state = State::where('code', strtoupper($data['state']))->first(); if (!$state) { $state = State::where('name', $data['state'])->first(); } if ($state) { $user->state()->associate($state); $user->country()->associate(Country::find($state->country_id)); } } $metadata = new Usermeta(); $metadata->first_name = $data['first_name']; $metadata->last_name = $data['last_name']; $metadata->email_optin = $data['email_optin']; $metadata->current_member = $data['current_member']; $metadata->current_member_number = $data['current_member_number']; try { $user->forceSave(); $user->metadata()->delete(); $user->metadata()->save($metadata); } catch (Exception $e) { var_dump($e); } }