本文整理汇总了PHP中Permission::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::where方法的具体用法?PHP Permission::where怎么用?PHP Permission::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permission
的用法示例。
在下文中一共展示了Permission::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showPermission
function showPermission($id)
{
$this->data['status'] = Session::has("status") ? Session::get("status") : FALSE;
$this->data['message'] = Session::has("message") ? Session::get("message") : "";
$this->data['id'] = $id;
// GET ALL PERMISSION
$permissions = Permission::where('group_id', $id)->get()->toArray();
$permissionMap = array();
// GET ALL MODULE
$moduleData = Modules::where('group_id', $id)->get()->toArray();
if (!empty($permissions)) {
foreach ($permissions as $permission) {
$permissionMap[$permission['module_id']][] = $permission;
}
}
if (!empty($moduleData)) {
$moduleData = array_column($moduleData, 'name', 'id');
}
// GET USER PERMISSION
$groupPermissions = Sentry::findGroupById($id)->getPermissions();
$this->data['permissionMap'] = $permissionMap;
$this->data['moduleData'] = $moduleData;
$this->data['groupPermissions'] = $groupPermissions;
if (Request::isMethod('post')) {
$this->postPermission($id, $this->data);
if ($this->data['status'] === TRUE) {
return Redirect::to($this->moduleURL . 'permission/' . $this->data['id']);
}
}
$this->layout->content = View::make('showPermission', $this->data);
}
示例2: run
public function run()
{
$admin = Role::where('name', '=', 'administrator')->first();
$perms = Permission::all();
$admin->perms()->sync(array_pluck($perms, 'id'));
$man = Role::where('name', '=', 'users manager')->first();
$perms = Permission::where('name', '=', 'manage_users')->orWhere('name', '=', 'delete_users')->get();
$man->perms()->sync(array_pluck($perms, 'id'));
$man = Role::where('name', '=', 'premium author')->first();
$perms = Permission::where('name', '=', 'manage_premium_casts')->orWhere('name', '=', 'manage_free_casts')->orWhere('name', '=', 'manage_series')->get();
$man->perms()->sync(array_pluck($perms, 'id'));
$man = Role::where('name', '=', 'author')->first();
$perms = Permission::where('name', '=', 'manage_free_casts')->orWhere('name', '=', 'manage_series')->get();
$man->perms()->sync(array_pluck($perms, 'id'));
$man = Role::where('name', '=', 'eraser')->first();
$perms = Permission::where('name', '=', 'delete_series')->orWhere('name', '=', 'delete_casts')->get();
$man->perms()->sync(array_pluck($perms, 'id'));
$man = Role::where('name', '=', 'premium user')->first();
$perms = Permission::where('name', '=', 'view_premium_casts')->orWhere('name', '=', 'view_free_casts')->get();
$man->perms()->sync(array_pluck($perms, 'id'));
$man = Role::where('name', '=', 'user')->first();
$perms = Permission::where('name', '=', 'view_free_casts')->get();
$man->perms()->sync(array_pluck($perms, 'id'));
$man = Role::where('name', '=', 'guest')->first();
$perms = Permission::where('name', '=', 'view_free_casts')->get();
$man->perms()->sync(array_pluck($perms, 'id'));
}
示例3: has_permission
/**
* Check if a role has a specific permission based on the permission $key
*
* @param string $key
* @param int $role_id
* @return bool
*/
public static function has_permission($key, $role_id)
{
if (!isset(static::$permission[$key])) {
static::$permission[$key] = \Permission::where('permission', '=', $key)->first(array('id'));
}
$relation = (bool) static::where('role_id', '=', $role_id)->where('permission_id', '=', static::$permission[$key]->id)->first(array('id'));
return $relation;
}
示例4: factory
public static function factory($id = null)
{
$instance = new Permission();
if (!empty($id)) {
$instance->where('id', $id)->get();
}
return $instance;
}
示例5: permission
function permission($module, $action)
{
$CI =& get_instance();
$permission = new Permission();
$perm = $permission->where("user_type_id = " . $CI->session->userdata('user_type') . " and module = '" . $module . "'")->get();
if ($perm->{$action}) {
return TRUE;
} else {
return FALSE;
}
}
示例6: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('c_m_p', function (Blueprint $table) {
$table->dropForeign('c_m_p_cjenovnik_id_foreign');
$table->dropForeign('c_m_p_mjera_id_foreign');
$table->dropForeign('c_m_p_predmet_id_foreign');
});
Schema::drop('c_m_p');
Schema::drop('cjenovnici');
Permission::where('ime', 'in', array(Permission::PERMISSION_VIEW_CJENOVNIK, Permission::PERMISSION_MANAGE_CJENOVNIK, Permission::PERMISSION_REMOVE_CJENOVNIK))->delete();
}
示例7: run
public function run()
{
$admin = new Role();
$admin->name = 'Admin';
$admin->save();
$managePages = Permission::where('name', '=', 'manage_pages')->first();
$manageUsers = Permission::where('name', '=', 'manage_users')->first();
$manageSermons = Permission::where('name', '=', 'manage_sermons')->first();
$admin->perms()->sync(array($managePages->id, $manageUsers->id, $manageSermons->id));
$member = new Role();
$member->name = 'Member';
$member->save();
}
示例8: checkRoute
public function checkRoute()
{
if (App::environment() == 'dev') {
return true;
}
$route = Route::currentRouteName();
$user_id = Auth::id();
$permission_object = Permission::where('route', '=', $route)->first();
$permission_id = $permission_object->id;
$count = $users = DB::table('permission_user')->where('permission_id', '=', $permission_id)->where('user_id', '=', $user_id)->count();
if ($count > 0) {
return true;
} else {
return false;
}
}
示例9: removePermission
public function removePermission()
{
$user_id = Input::get("user");
$permission_id = Input::get("permission");
$user = User::find($user_id);
$permission = PermissionDefinition::find($permission_id);
if ($user) {
if ($permission) {
Permission::where(['permission_id' => $permission_id, 'user_id' => $user_id])->delete();
return Redirect::to('/dashboard/storyteller/manage/permissions');
} else {
return Response::json(['success' => false, 'message' => 'Invalid permission definition.']);
}
} else {
return Response::json(['success' => false, 'message' => 'Invalid user.']);
}
}
示例10: run
public function run()
{
//DB::table('assigned_roles')->delete();
//DB::table('roles')->delete();
$admin = Role::create(array('name' => 'admin'));
$student = Role::create(array('name' => 'student'));
$teacher = Role::create(array('name' => 'teacher'));
$permisos = Permission::all();
foreach ($permisos as $permiso) {
$admin->attachPermission($permiso);
}
$permiso = Permission::where('name', '=', 'crear_examen')->get()->first();
$teacher->attachPermission($permiso);
$permiso = Permission::where('name', '=', 'eliminar_examen')->get()->first();
$teacher->attachPermission($permiso);
$permiso = Permission::where('name', '=', 'modificar_examen')->get()->first();
$teacher->attachPermission($permiso);
$permiso = Permission::where('name', '=', 'realizar_examen')->get()->first();
$student->attachPermission($permiso);
$permiso = Permission::where('name', '=', 'ver_resultado_examen')->get()->first();
$student->attachPermission($permiso);
}
示例11: update
/**
* Update the specified resource in storage.
* PUT /roles/{id}
*
* @param int $id
* @return Response
*/
public function update($id)
{
$role = Role::findOrFail($id);
if ($role) {
$perms = Input::get('perms');
$permsToAttach = [];
if (Input::has('perms')) {
foreach ($perms as $key => $value) {
$perm = Permission::where('id', '=', $key)->first();
if ($perm) {
array_push($permsToAttach, $perm->id);
}
}
}
$role->perms()->sync($permsToAttach);
if (Input::has('display_name')) {
$role->display_name = Input::get('display_name');
}
$role->save();
return Redirect::to('admin/roles')->with(['roles-notice' => 'Role has been updated']);
}
return Redirect::to('admin/roles')->with(['roles-notice' => 'Error updating role']);
}
示例12: run
public function run()
{
$roles = [['name' => 'Administrator', 'weight' => 3], ['name' => 'Moderator', 'weight' => 2], ['name' => 'User', 'weight' => 1]];
$permissions = [['weight' => '1', 'node' => 'quote.editor', 'description' => 'The ability to use the editor'], ['weight' => '1', 'node' => 'quote.edit', 'description' => 'The ability to edit an existing quote'], ['weight' => '2', 'node' => 'quote.edit.others', 'description' => 'The ability to edit an existing quote that isn\'t yours'], ['weight' => '1', 'node' => 'quote.new', 'description' => 'The ability to create a new quote'], ['weight' => '2', 'node' => 'quote.approve', 'description' => 'The ability to approve a quote'], ['weight' => '2', 'node' => 'quote.deny', 'description' => 'The ability to deny a quote'], ['weight' => '1', 'node' => 'quote.upvote', 'description' => 'The ability to upvote a quote'], ['weight' => '1', 'node' => 'quote.downvote', 'description' => 'The ability to downvote a quote'], ['weight' => '1', 'node' => 'quote.favorite', 'description' => 'The ability to create favorites'], ['weight' => '1', 'node' => 'user.preferences', 'description' => 'The ability to access user preferences'], ['weight' => '3', 'node' => 'site.preferences', 'description' => 'The ability to access site preferences']];
foreach ($permissions as $permission) {
$perm = Permission::firstOrNew(['node' => $permission['node']]);
$perm->description = $permission['description'];
$perm->save();
}
foreach ($roles as $r) {
$this->command->info('Adding permissions to ' . $r['name']);
$role = Role::where('name', $r['name'])->first();
foreach ($permissions as $p) {
if ($p['weight'] <= $r['weight']) {
$this->command->info('Giving ' . $r['name'] . ' the ' . $p['node'] . ' node');
$permission = Permission::where('node', $p['node'])->first();
if (!$role->permissions->contains($permission->id)) {
$role->permissions()->attach($permission);
}
}
}
}
}
示例13: permission
function permission($module, $action, $id = null)
{
$CI =& get_instance();
$foo = new Permission();
if ($id) {
$foobar = $foo->where("user_type_id", $id)->where("module", $module)->get(1);
if ($foobar->{$action}) {
return TRUE;
} else {
return FALSE;
}
} else {
if (user()->fd_admin == 1) {
return TRUE;
} else {
$foobar = $foo->where("user_type_id", user()->user_type_id)->where("module", $module)->get(1);
if ($foobar->{$action}) {
return TRUE;
} else {
return FALSE;
}
}
}
}
示例14: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
if (ACL::checkUserPermission('permission.delete') == false) {
return Redirect::action('dashboard');
}
$permission = Permission::where('id', $id)->find($id);
if (!empty($permission)) {
$permission->delete();
$messageType = 'success';
$message = 'Permission delete success';
} else {
$messageType = 'error';
$message = 'Permission delete failed';
}
return Redirect::action('settings.permission')->with($messageType, $message);
}
示例15: getPermission
public function getPermission()
{
$this->getUser();
$this->permission = Permission::where('name', 'TestPermission')->first();
}