本文整理汇总了PHP中Number::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Number::save方法的具体用法?PHP Number::save怎么用?PHP Number::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Number
的用法示例。
在下文中一共展示了Number::save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$nexmo = new NexmoAccount(Cache::get('NEXMO_KEY', getenv('NEXMO_KEY')), Cache::get('NEXMO_SECRET', getenv('NEXMO_SECRET')));
$isBought = $nexmo->buyNumber(Input::get('country_code'), Input::get('number'));
if ($isBought) {
Pusherer::trigger('boom', 'update_balance', $nexmo->getBalance());
$number = new Number();
$number->number = Input::get('number');
$number->country_code = Input::get('country_code');
$number->type = Input::get('type');
$number->features = explode(',', Input::get('features'));
$number->save();
return $number;
}
return $this->response->errorInternal();
}
示例2: echo_test
public static function echo_test()
{
$featureCode = new FeatureCode();
$featureCode['name'] = 'Echo Test';
$featureCode['registry'] = array('feature' => 'echo');
$featureCode->save();
try {
$location = Doctrine::getTable('Location')->findAll();
if (!$location->count()) {
throw Exception('Could not find location id');
}
$location_id = arr::get($location, 0, 'location_id');
$number = new Number();
$number['user_id'] = users::getAttr('user_id');
$number['number'] = '9999';
$number['location_id'] = $location_id;
$number['registry'] = array('ignoreFWD' => '0', 'ringtype' => 'ringing', 'timeout' => 20);
$dialplan = array('terminate' => array('transfer' => 0, 'voicemail' => 0, 'action' => 'hangup'));
$number['dialplan'] = $dialplan;
$number['class_type'] = 'FeatureCodeNumber';
$number['foreign_id'] = $featureCode['feature_code_id'];
$context = Doctrine::getTable('Context')->findOneByName('Outbound Routes');
$number['NumberContext']->fromArray(array(0 => array('context_id' => $context['context_id'])));
$numberType = Doctrine::getTable('NumberType')->findOneByClass('FeatureCodeNumber');
if (empty($numberType['number_type_id'])) {
return FALSE;
}
$number['NumberPool']->fromArray(array(0 => array('number_type_id' => $numberType['number_type_id'])));
$number->save();
return $number['number_id'];
} catch (Exception $e) {
kohana::log('error', 'Unable to initialize device number: ' . $e->getMessage());
throw $e;
}
}
示例3: postSetupNexmo
public function postSetupNexmo()
{
$nexmo_key = Input::get('nexmo_key');
$nexmo_secret = Input::get('nexmo_secret');
$nexmo = new NexmoAccount($nexmo_key, $nexmo_secret);
try {
// check nexmo credentials
$credit_balance = $nexmo->getBalance();
// check db connection
DB::connection()->getDatabaseName();
// migrate db
Artisan::call('migrate');
// truncate number table
DB::table('number')->truncate();
// set nexmo credentials to env
Cache::forever('NEXMO_KEY', $nexmo_key);
Cache::forever('NEXMO_SECRET', $nexmo_secret);
// add numbers to db
$numbers = $nexmo->getInboundNumbers();
if ($numbers['count'] > 0) {
foreach ($numbers['numbers'] as $num) {
$number = new Number();
$number->number = $num['msisdn'];
$number->country_code = $num['country'];
$number->type = $num['type'];
$number->features = $num['features'];
$number->voice_callback_type = $num['voiceCallbackType'];
$number->voice_callback_value = $num['voiceCallbackValue'];
$number->save();
}
}
// set dn callback url
// $nexmo->updateAccountSettings(array('drCallBackUrl' => url('callback/dn')));
Queue::getIron()->addSubscriber('setupDnCallbackUrl', array('url' => url('queue/receive')));
Queue::push('HomeController@setupDnCallbackUrl', array('nexmo_key' => $nexmo_key, 'nexmo_secret' => $nexmo_secret), 'setupDnCallbackUrl');
// set balance to cache
Cache::put('nexmo', $credit_balance, 10);
if (Auth::check()) {
return Redirect::to('/');
}
return Redirect::to('/register');
} catch (Exception $e) {
return Redirect::to('start')->with('message', $e->__toString());
}
}
示例4: getAll
function getAll()
{
$start_date = strtotime('1.1.2011');
$end_date = strtotime("now");
$data = array();
while ($start_date < $end_date) {
$date = date('d/m/Y', $start_date);
$url = 'http://ketqua.net/xo-so-truyen-thong.php?ngay=' . $date;
$db = $this->getDetail($url);
//insert to database
$number = new Number();
$number->number = $db;
$number->day = date('d', $start_date);
$number->month = date('m', $start_date);
$number->year = date('y', $start_date);
$number->date = $date;
$number->save();
echo $db . ' | ' . $date . ' | ' . $url . PHP_EOL;
$start_date = strtotime('+1 day', $start_date);
$data[] = $db;
}
return $data;
}
示例5: createNumber
private function createNumber($deviceId, $username)
{
$emailParts = explode('@', $username);
$number = new Number();
$number['number'] = $emailParts[0];
$number['type'] = Number::TYPE_INTERNAL;
$number['status'] = Number::STATUS_NORMAL;
$number['location_id'] = 1;
$number['account_id'] = 1;
$number['foreign_id'] = $deviceId;
//save number
Doctrine::getTable('Number')->getRecordListener()->get('MultiTenant')->setOption('disabled', TRUE);
$numberId = $number->save();
Doctrine::getTable('Number')->getRecordListener()->get('MultiTenant')->setOption('disabled', FALSE);
return $numberId;
}
示例6: createExtensionNumber
public static function createExtensionNumber()
{
extract(Event::$data);
Doctrine::getTable('Number')->getRecordListener()->get('MultiTenant')->setOption('disabled', TRUE);
try {
if (empty($location_id)) {
$locations = Doctrine_Query::create()->from('Location')->where('account_id = ?', array($account_id))->execute();
if (empty($locations[0]['location_id'])) {
kohana::log('error', 'Unable to initialize device number: could not determine location_id');
return;
}
$location_id = $locations[0]['location_id'];
}
$number = new Number();
$number['user_id'] = $user_id;
$number['number'] = $extension;
$number['location_id'] = $location_id;
$number['registry'] = array('ignoreFWD' => '0', 'ringtype' => 'ringing', 'timeout' => 20);
$dialplan = array('terminate' => array('transfer' => 0, 'voicemail' => 0, 'action' => 'hangup'));
if (!empty($device['plugins']['voicemail']['mwi_box'])) {
$dialplan['terminate']['voicemail'] = $device['plugins']['voicemail']['mwi_box'];
$dialplan['terminate']['action'] = 'voicemail';
}
$number['dialplan'] = $dialplan;
$number['class_type'] = 'DeviceNumber';
$number['foreign_id'] = $device['device_id'];
$number['NumberContext']->fromArray(array(0 => array('context_id' => $context_id)));
$numberType = Doctrine::getTable('NumberType')->findOneByClass('DeviceNumber');
if (empty($numberType['number_type_id'])) {
return;
}
$number['NumberPool']->fromArray(array(0 => array('number_type_id' => $numberType['number_type_id'])));
$number['account_id'] = $account_id;
$number->save();
} catch (Exception $e) {
kohana::log('error', 'Unable to initialize device number: ' . $e->getMessage());
throw $e;
}
Doctrine::getTable('Number')->getRecordListener()->get('MultiTenant')->setOption('disabled', FALSE);
}
示例7: ivrReturn
public static function ivrReturn($account_id, $location_id, $user_id)
{
if (!class_exists('FeatureCode')) {
return FALSE;
}
$featureCode = new FeatureCode();
$featureCode['name'] = 'Return from IVR';
$featureCode['registry'] = array('feature' => 'ivr_return');
$featureCode->save();
try {
$number = new Number();
$number['user_id'] = $user_id;
$number['number'] = '2097';
$number['location_id'] = $location_id;
$number['registry'] = array('ignoreFWD' => '0', 'ringtype' => 'ringing', 'timeout' => 20);
$dialplan = array('terminate' => array('transfer' => 0, 'voicemail' => 0, 'action' => 'hangup'));
$number['dialplan'] = $dialplan;
$number['class_type'] = 'FeatureCodeNumber';
$number['foreign_id'] = $featureCode['feature_code_id'];
$context = Doctrine::getTable('Context')->findOneByName('Outbound Routes');
$number['NumberContext']->fromArray(array(0 => array('context_id' => $context['context_id'])));
$numberType = Doctrine::getTable('NumberType')->findOneByClass('FeatureCodeNumber');
if (empty($numberType['number_type_id'])) {
return FALSE;
}
$number['NumberPool']->fromArray(array(0 => array('number_type_id' => $numberType['number_type_id'])));
$number->save();
return $number['number_id'];
} catch (Exception $e) {
kohana::log('error', 'Unable to initialize device number: ' . $e->getMessage());
throw $e;
}
}