本文整理汇总了PHP中app\models\Permission::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::save方法的具体用法?PHP Permission::save怎么用?PHP Permission::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Permission
的用法示例。
在下文中一共展示了Permission::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$permissions = new Permission();
$permissions->name = 'can-access';
$permissions->display_name = "Dapat Mengakses";
$permissions->description = "Fungsi Permission";
$permissions->access = "true";
$permissions->action = "access";
$permissions->save();
$permissions = new Permission();
$permissions->name = 'can-add';
$permissions->display_name = "Dapat Menambah";
$permissions->description = "Fungsi Permission";
$permissions->access = "true";
$permissions->action = "add";
$permissions->save();
$permissions = new Permission();
$permissions->name = 'can-edit';
$permissions->display_name = "Dapat Mengubah";
$permissions->description = "Fungsi Permission";
$permissions->access = "true";
$permissions->action = "edit";
$permissions->save();
$permissions = new Permission();
$permissions->name = 'can-delete';
$permissions->display_name = "Dapat Menghapus";
$permissions->description = "Fungsi Permission";
$permissions->access = "true";
$permissions->action = "delete";
$permissions->save();
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
// $u1 = \App\User::create(
// ['name'=>'super_admin', 'email'=>'super_admin@oa.com', 'password'=>Hash::make('123456')]
// );
$user = \App\User::where('email', '=', 'super_admin@oa.com')->first();
echo $user . "\n";
// $role = new \App\Models\Role();
// $role->name = 'SuperUser';
// $role->display_name = '超级管理员'; // optional
// $role->description = '网站超管'; // optional
// $role->save();
$role = \App\Models\Role::where('name', '=', 'SuperUser')->first();
echo $role . "\n";
//
// $user->attachRole($role);
//
$permission = new \App\Models\Permission();
$permission->name = 'create-post';
$permission->display_name = 'Create Posts';
// optional
$permission->description = 'create new blog posts';
// optional
$permission->save();
$role->attachPermission($permission);
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('permissions')->delete();
/**
* Permission Attributes
*
* name: Unique name for the permission, used for looking up permission information in the
* application layer. For example: "create-post", "edit-user", "post-payment", "mailing-list-subscribe".
*
* display_name: Human readable name for the permission. Not necessarily unique, and is optional.
* For example "Create Posts", "Edit Users", "Post Payments", "Subscribe to mailing list".
*
* description: A more detailed explanation of the Permission. This is also optional.
*/
$permissions = array(self::pArray(PermissionNames::CreateConference(), "Create Conference"), self::pArray(PermissionNames::ManageGlobalPermissions(), "Manage Global Permissions"), self::pArray(PermissionNames::ApproveUserRegistration(), "Approve User Registration"), self::pArray(PermissionNames::ViewSiteStatistics(), "View Site Statistics"), self::pArray(PermissionNames::ManageAccounts(), "Manage Accounts"));
foreach ($permissions as $p) {
$entry = new Permission();
$entry->name = $p['name'];
if (array_key_exists('display_name', $p)) {
$entry->display_name = $p['display_name'];
}
if (array_key_exists('description', $p)) {
$entry->description = $p['description'];
}
$entry->save();
}
}
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$permission = new Permission();
$permission->level = 3;
$permission->permission = "posts_manage";
$permission->save();
$permission = new Permission();
$permission->level = 4;
$permission->permission = "users_manage";
$permission->save();
$permission = new Permission();
$permission->level = 5;
$permission->permission = "permissions_manage";
$permission->save();
$permission = new Permission();
$permission->level = 5;
$permission->permission = "user_accesses_manage";
$permission->save();
User::create(['name' => "admin", 'email' => "admin@admin.ru", 'password' => bcrypt("admin")]);
$user = User::whereEmail("admin@admin.ru")->first();
$access = new UserAccess();
$access->level = 5;
$access->description = "Is automated created admin user";
$access->user_id = $user->id;
$access->save();
}
示例5: run
public function run()
{
$adminEmail = Config::get('madison.seeder.admin_email');
$admin = new Role();
$admin->name = 'Admin';
$admin->save();
$independent_sponsor = new Role();
$independent_sponsor->name = 'Independent Sponsor';
$independent_sponsor->save();
$permIds = array();
foreach ($this->adminPermissions as $permClass => $data) {
$perm = new Permission();
foreach ($data as $key => $val) {
$perm->{$key} = $val;
}
$perm->save();
$permIds[] = $perm->id;
}
$admin->perms()->sync($permIds);
$user = User::where('email', '=', $adminEmail)->first();
$user->attachRole($admin);
$createDocPerm = new Permission();
$createDocPerm->name = "independent_sponsor_create_doc";
$createDocPerm->display_name = "Independent Sponsoring";
$createDocPerm->save();
$independent_sponsor->perms()->sync(array($createDocPerm->id));
}
示例6: save
public function save(Request $request)
{
$as = $request->input('as');
$permission = new Permission();
$validator = \Validator::make($request->all(), $permission->getRules());
$results = new \StdClass();
if ($validator->passes()) {
if ($request->input('id') != "xxx") {
$permission = Permission::find($request->input('id'));
$permission->name = $request->input('name');
$permission->display_name = $request->input('displayname');
$permission->description = $request->input('description');
$permission->save();
$results->info = 'permission create';
} else {
$permission = new Permission();
$permission->name = $request->input('name');
$permission->display_name = $request->input('displayname');
$permission->description = $request->input('description');
$permission->save();
$results->info = 'permission edit';
}
$results->status = 1;
$results->result = $permission;
} else {
$results->status = 0;
$result = array();
foreach ($validator->errors() as $key => $err) {
array_push($result, $err);
}
$results->result = $result;
}
return response()->json($results);
}
示例7: setupRolesPermissions
public function setupRolesPermissions()
{
$master = User::findOrFail(1);
if ($master) {
// Create role
$owner = new Role();
$owner->name = 'master';
$owner->display_name = 'Project Owner';
$owner->description = 'The Master of Universe';
$owner->save();
// Create permissions
$createUser = new Permission();
$createUser->name = 'user-create';
$createUser->display_name = 'Create Users';
$createUser->description = 'Create new users';
$createUser->save();
$editUser = new Permission();
$editUser->name = 'user-edit';
$editUser->display_name = 'Edit Users';
$editUser->description = 'Edit existing users';
$editUser->save();
$deleteUser = new Permission();
$deleteUser->name = 'user-delete';
$deleteUser->display_name = 'Delete Users';
$deleteUser->description = 'Delete existing users';
$deleteUser->save();
// Attach permissions
$owner->attachPermissions([$createUser, $editUser, $deleteUser]);
// Attach roles
$master->attachRole($owner);
// using facade
}
return redirect()->route('access.test');
}
示例8: createPermission
private static function createPermission($name)
{
$permission = new Permission();
$permission->name = $name;
$permission->save();
return $permission;
}
示例9: store
public function store(Request $request)
{
$permission = new Permission();
$permission->name = $request->name;
$permission->label = $request->label;
$permission->save();
return redirect()->action('Admin\\PermissionsController@index');
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store()
{
//
$data = new Permission();
$data->display_name = Input::get('display_name');
$data->name = Input::get('name');
$data->desc = Input::get('desc');
$data->save();
return redirect()->route('admin.permission.index');
}
示例11: save_permission
public function save_permission()
{
//dd(Input::get('role_name'));
$permissions = new Permission();
$permissions->name = Input::get('pname');
$permissions->display_name = Input::get('display_name');
$permissions->description = Input::get('description');
$permissions->save();
return redirect()->route('permissions');
}
示例12: editSave
public function editSave(Request $request)
{
$allowed = array('png', 'jpg', 'gif');
$hasil = false;
$image = 'holder.js/180x180';
$results = new \StdClass();
$validator = \Validator::make($request->all(), ['nama' => 'required', 'mode' => 'required']);
$destination = ParentFrontpage::UPLOAD_PATH;
$result = '';
if ($validator->passes()) {
if ($request->has('id') && $request->input('id') != 'xxx') {
$result = ParentFrontpage::find($request->input('id'));
$results->info = 'menu frontpage update';
$results->status = 1;
$permission = Permission::where('name', $result->nama)->get()->first();
} else {
$result = new ParentFrontpage();
$results->info = 'menu frontpage create';
$results->status = 1;
$permission = new Permission();
}
$results->message = 'Proses Pengubahan Menu Sukses!';
$result->nama = $request->input('nama');
$result->mode = $request->input('mode');
$result->redirect = $request->input('redirect');
$result->public_key = $request->input('puKey');
$result->private_key = $request->input('prKey');
$result->query = $request->input('query');
$result->db_host = $request->input('dbhost');
$result->db_user = $request->input('dbuser');
$result->db_pass = $request->input('dbpass');
if ($request->hasFile('image')) {
if ($request->file('image')->isValid()) {
$filename = date('YmdHis') . str_pad(rand(0, 1000), 4, 0, STR_PAD_LEFT) . '.' . $request->file('image')->guessExtension();
$img = \Image::make($request->file('image'))->fit(180, 180)->save($destination . $filename);
$result->image = $filename;
}
}
$result->save();
$permission->name = $request->input('nama');
$permission->display_name = 'Dapat Mengakses ' . $request->input('nama');
$permission->description = 'Dapat Mengakses ' . $request->input('nama');
$permission->access = 'access';
$permission->action = $result->id;
$permission->type = 'app';
$permission->save();
$results->info = 'permission create';
} else {
$results->info = 'menu frontpage';
$results->status = 0;
$results->message = 'Proses Pengubahan Menu Gagal!';
}
$results->result = $result;
return response()->json($results);
}
示例13: addPermission
public static function addPermission($name, $label = null, $description = null)
{
$permission = Permission::where('name', $name)->first();
if (!$permission) {
$permission = new Permission(['name' => $name]);
}
$permission->label = $label;
$permission->description = $description;
$permission->save();
return $permission;
}
示例14: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
$this->validate($request, ['name' => 'required|alpha_dash|unique:permissions|max:255', 'display_name' => 'required|max:255']);
$permission = new Permission();
$permission->name = e($request->name);
$permission->display_name = e($request->display_name);
if ($permission->save()) {
return Redirect::to('admin/permissions');
} else {
return Redirect::back()->withInput($request->input())->withErrors('保存失败!');
}
}
示例15: addMenuAction
public function addMenuAction(Request $request)
{
if ($request->action == 'update') {
try {
$fun = Permission::where('id', $request->col0)->update(['name' => $request->col1, 'display_name' => $request->col2, 'description' => $request->col3, 'link' => $request->col4, 'parent' => $request->col5, 'icon' => $request->col6]);
Log::info($fun);
if ($fun) {
return response(array('sukses bisa bro!!', $request->all()), 200)->header('Content-Type', 'application/json');
} else {
return response('There is no data changes!!', 400)->header('Content-Type', 'application/json');
}
} catch (PDOException $exception) {
Log::info($exception->getMessage());
return response('Proses Gagal!!', 400)->header('Content-Type', 'application/json');
}
}
if ($request->action == 'insert') {
try {
$fun = new Permission();
$fun->name = $request->col1;
$fun->display_name = $request->col2;
$fun->description = $request->col3;
$fun->link = $request->col4;
$fun->parent = $request->col5;
$fun->icon = $request->col6;
if ($fun->save()) {
$request->merge(array('col0' => $fun->id));
return response(array('sukses bisa bro!!', $request->all()), 200)->header('Content-Type', 'application/json');
} else {
return response('There is no data changes!!', 400)->header('Content-Type', 'application/json');
}
} catch (PDOException $exception) {
Log::info($exception->getMessage());
return response('Proses Gagal!!', 400)->header('Content-Type', 'application/json');
}
}
if ($request->action == 'delete') {
try {
$fun = Permission::where('ID', $request->col0);
if ($fun->delete()) {
return response(array('sukses bisa bro!!', $request->all()), 200)->header('Content-Type', 'application/json');
} else {
return response('There is no data changes!!', 400)->header('Content-Type', 'application/json');
}
} catch (PDOException $exception) {
Log::info($exception->getMessage());
return response('Proses Gagal!!', 400)->header('Content-Type', 'application/json');
}
}
//return response(array('sukses bisa bro!!'), 200)
return response('Proses Gagal!!', 400)->header('Content-Type', 'application/json');
}