本文整理汇总了PHP中License::generate方法的典型用法代码示例。如果您正苦于以下问题:PHP License::generate方法的具体用法?PHP License::generate怎么用?PHP License::generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类License
的用法示例。
在下文中一共展示了License::generate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postGenerateLicense
/**
* Generate license
*/
public function postGenerateLicense()
{
$rules = array('transaction_id' => 'required');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('admin/utilities/generate-license')->withErrors($validator)->withInput();
} else {
$transaction_id = Input::get('transaction_id');
if ($transaction = Transaction::where('id', '=', $transaction_id)->first()) {
if ($license = License::where('transaction_id', '=', $transaction_id)->first()) {
Session::flash('alert_error', '<strong>Ooops!</strong> License for given transaction already exists.');
return Redirect::to('admin/licenses?q=' . $license->license_key . '¶m=key');
}
$plan = Plan::where('id', '=', $transaction->plan_id)->first();
if ($plan->has_license) {
$product = Product::where('id', '=', $plan->product_id)->first();
$license_key = License::generate($product->code);
// Save license
$license = new License();
$license->license_key = $license_key;
$license->transaction_id = $transaction_id;
$license->allowed_usage = $plan->license_allowed_usage;
$license->save();
Session::flash('alert_message', '<strong>Well done!</strong> You successfully have generated license key.');
return Redirect::to('admin/licenses?q=' . $license_key . '¶m=key');
} else {
Session::flash('alert_error', '<strong>Ooops!</strong> This plan does not allow to generate a license key.');
return Redirect::to('admin/utilities/generate-license');
}
} else {
Session::flash('alert_error', '<strong>Ooops!</strong> Transaction was not found.');
return Redirect::to('admin/utilities/generate-license');
}
}
}
示例2: postGenerateLicense
/**
* Generate License
*
* Generate license of any product
*/
public function postGenerateLicense()
{
//if($this->_isValidRequest())
//{
$prefix = Input::get('code');
$transaction_id = Input::get('transaction_id');
$allowed_usage = Input::get('allowed_usage');
if (!$transaction_id) {
$this->_invalidRequest("Transaction ID parameter is required");
}
if (!$allowed_usage) {
$this->_invalidRequest("Allowed Usage parameter is required");
}
// Check if license is already created for given transaction
if (License::where('transaction_id', '=', $transaction_id)->first()) {
$this->_invalidRequest("License already exists for transaction with ID: {$transaction_id}");
}
$license_key = License::generate($prefix);
// Save license
$license = new License();
$license->license_key = $license_key;
$license->transaction_id = $transaction_id;
$license->allowed_usage = $allowed_usage;
$license->save();
$data = array('license_key' => $license_key);
die(json_encode(array('data' => $data)));
//}
}
示例3: _generate_license
/**
* Generate and store license in database
*/
private function _generate_license($product, $plan, $transaction_id)
{
if ($plan->has_license) {
$license_key = License::generate($product->code);
// Save license
$license = new License();
$license->license_key = $license_key;
$license->transaction_id = $transaction_id;
$license->allowed_usage = $plan->license_allowed_usage;
$license->save();
return $license_key;
}
}