本文整理匯總了PHP中app\Permission::doCreate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Permission::doCreate方法的具體用法?PHP Permission::doCreate怎麽用?PHP Permission::doCreate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Permission
的用法示例。
在下文中一共展示了Permission::doCreate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createNew
public function createNew()
{
//create transaction method
try {
$new = DB::transaction(function () {
//define rules for the features.
$feature_rules = ['name' => 'required', 'url' => 'required', 'icon' => 'required', 'module' => 'required|unique:features'];
//get the form inputs from the POST
$inputs = Input::all();
//create new feature object, compare input with rules and after that create new entry into db
$feature = new Feature();
$feature_result = $feature->doCreate($inputs, $feature_rules);
if ($feature_result['status'] != 1) {
throw new Exception($feature_result['message']);
}
//if CRUD is selected.
if ($inputs['crud'] == '1') {
//define rules for permission
$permission_rules = ValidationRule::$permissionCreate;
// create inputs field for permission that need to be created - RestFul
$permission_inputs = array(['feature_id' => $feature_result['data']['id'], 'name' => 'create', 'descr' => 'Create Form', 'module' => $feature_result['data']['module'], 'position' => 'panel-default', 'url' => '/crm/' . $feature_result['data']['module'] . '/create', 'icon' => 'fa-plus', 'icon_bg' => 'btn-primary', 'page' => 'index', 'prompt_type' => 'none', 'prompt_title' => null, 'prompt_content' => null], ['feature_id' => $feature_result['data']['id'], 'name' => 'store', 'descr' => 'store record', 'module' => $feature_result['data']['module'], 'position' => 'form', 'url' => '/crm/' . $feature_result['data']['module'], 'icon' => null, 'icon_bg' => null, 'page' => 'index', 'prompt_type' => 'none', 'prompt_title' => null, 'prompt_content' => null], ['feature_id' => $feature_result['data']['id'], 'name' => 'show', 'descr' => 'Show Details', 'module' => $feature_result['data']['module'], 'position' => 'table', 'url' => '/crm/' . $feature_result['data']['module'] . '/[ID]', 'icon' => 'fa-file-text-o', 'icon_bg' => 'btn-success', 'page' => 'index', 'prompt_type' => 'none', 'prompt_title' => null, 'prompt_content' => null], ['feature_id' => $feature_result['data']['id'], 'name' => 'edit', 'descr' => 'Edit Details', 'module' => $feature_result['data']['module'], 'position' => 'table', 'url' => '/crm/' . $feature_result['data']['module'] . '/[ID]/edit', 'icon' => 'fa-edit', 'icon_bg' => 'btn-warning', 'page' => 'index', 'prompt_type' => 'none', 'prompt_title' => null, 'prompt_content' => null], ['feature_id' => $feature_result['data']['id'], 'name' => 'update', 'descr' => 'Update Details', 'module' => $feature_result['data']['module'], 'position' => 'form', 'url' => '/crm/' . $feature_result['data']['module'] . '/[ID]', 'icon' => null, 'icon_bg' => null, 'page' => 'index', 'prompt_type' => 'none', 'prompt_title' => null, 'prompt_content' => null], ['feature_id' => $feature_result['data']['id'], 'name' => 'destroy', 'descr' => 'Delete Record', 'module' => $feature_result['data']['module'], 'position' => 'table', 'url' => '/crm/' . $feature_result['data']['module'] . '/[ID]', 'icon' => 'fa-times', 'icon_bg' => 'btn-primary', 'page' => 'index', 'prompt_type' => 'confirm', 'prompt_title' => 'Delete', 'prompt_content' => 'Are you sure you wan to delete this record?'], ['feature_id' => $feature_result['data']['id'], 'name' => 'multi_destroy', 'descr' => 'Delete Multiple Record', 'module' => $feature_result['data']['module'], 'position' => 'panel-alert', 'url' => '/crm/' . $feature_result['data']['module'] . '/multi_destroy', 'icon' => 'fa-times', 'icon_bg' => 'btn-primary', 'page' => 'index', 'prompt_type' => 'confirm', 'prompt_title' => 'Delete', 'prompt_content' => 'Are you sure you wan to delete this record?']);
// foreach of the permission, insert into the db.
foreach ($permission_inputs as $permission_input) {
$permission = new Permission();
$permission_create = $permission->doCreate($permission_input, $permission_rules);
if ($permission_create['status'] != 1) {
throw new Exception($permission_create['message']);
}
}
}
#end if
//if everything OK return success
return Redirect::to('/crm/feature')->withMessage(Generate::message('SUCCESS', 'Success Create'));
});
#end transaction
} catch (Exception $e) {
return Redirect::to('/crm/feature')->withMessage(Generate::message('FAIL', $e->getMessage()));
}
return $new;
}