本文整理汇总了PHP中Permission::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::select方法的具体用法?PHP Permission::select怎么用?PHP Permission::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permission
的用法示例。
在下文中一共展示了Permission::select方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of permissions
*
* @return Response
*/
public function index()
{
if (!Permission::canList()) {
return $this->_access_denied();
}
if (Request::ajax()) {
$permissions = Permission::select(['id', 'group_name', 'name', 'display_name']);
return Datatables::of($permissions)->add_column('actions', function ($data) {
$actions = [];
$actions[] = $data->canShow() ? link_to_action('permissions.show', 'Show', $data->id, ['class' => 'btn btn-xs btn-primary']) : '';
$actions[] = $data->canUpdate() ? link_to_action('permissions.edit', 'Update', $data->id, ['class' => 'btn btn-xs btn-default']) : '';
$actions[] = $data->canDelete() ? Former::open(action('permissions.destroy', $data->id))->class('form-inline') . Former::hidden('_method', 'DELETE') . '<button type="button" class="btn btn-danger btn-xs confirm-delete">Delete</button>' . Former::close() : '';
return implode(' ', $actions);
})->remove_column('id')->make();
}
Asset::push('js', 'datatables');
return View::make('permissions.index');
}
示例2: updateRole
public function updateRole()
{
$prevURL = Request::header('referer');
if (!Request::isMethod('post')) {
return App::abort(404);
}
if (Input::has('id')) {
try {
$role = Role::findorFail((int) Input::get('id'));
} catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) {
return App::abort(404);
}
$create = false;
$message = 'has been updated successful';
} else {
$create = true;
$role = new Role();
$message = 'has been added successful';
}
$role->name = Input::has('name') ? Input::get('name') : '';
$pass = $role->valid();
if ($pass->passes()) {
Permission::generatePermission();
$role->save();
if (Input::has('permission')) {
$arrAssignedPermission = [];
$arrPermission = Input::get('permission');
foreach ($arrPermission as $controller => $permission) {
foreach ($permission as $action => $type) {
$currentPerrmission = Permission::select('id')->where('name', 'like', "%{$controller}_{$action}_%")->where('name', '<>', "{$controller}_{$action}_{$type}")->get();
if (!$currentPerrmission->isEmpty()) {
$arrId = [];
foreach ($currentPerrmission as $id) {
$arrId[] = $id->id;
}
DB::table('permission_role')->where('role_id', $role->id)->whereIn('permission_id', $arrId)->delete();
unset($currentPerrmission, $arrId);
}
if ($type != 'none') {
$permission_id = Permission::where('name', "{$controller}_{$action}_{$type}")->pluck('id');
if (is_null($permission_id)) {
continue;
}
$arrAssignedPermission[] = $permission_id;
}
}
}
if (!empty($arrAssignedPermission)) {
$role->perms()->sync($arrAssignedPermission);
}
Cache::tags('menu', 'frontend')->flush();
Cache::tags('menu', 'backend')->flush();
}
if (Input::has('continue')) {
if ($create) {
$prevURL = URL . '/admin/roles/edit-role/' . $role->id;
}
return Redirect::to($prevURL)->with('flash_success', "<b>{$role->name}</b> {$message}.");
}
return Redirect::to(URL . '/admin/roles')->with(['flash_success' => "{$role->name} {$message}."]);
}
return Redirect::to($prevURL)->with(['flash_error' => $pass->messages()->all()])->withInput();
}
示例3: checkPermisssions
function checkPermisssions($id)
{
# select p.ID_CATEGORIAS, p.ID_SUBCATEGORIAS
# from permissoes p
# left join usuarios g on (p.TIPO = 'G') and (g.ID_GRUPO_USUARIOS = p.ID_ESTRANGEIRO )
# left join usuarios u on (p.TIPO = 'U') and (u.ID = p.ID_ESTRANGEIRO )
# where ( p.ID_ESTRANGEIRO = 1 )
$p = Permission::select('permissions.id_category', 'permissions.id_subcategory')->leftJoin('users AS g', function ($join) {
$join->on('g.id_usergroup', '=', 'permissions.id_fk')->where('permissions.type', '=', "'G'");
})->leftJoin('users AS u', function ($join) {
$join->on('u.id', '=', 'permissions.id_fk')->where('permissions.type', '=', "'U'");
})->where("permissions.id_fk", '=', $id)->get();
$error = false;
$mensagem = '';
if (count($p) < 1) {
$error = true;
$mensagem = 'Nenhum registro encontrado';
}
return $p;
}
示例4: getErrorOrSync
/**
*
* @param array $input
* @return string|null
*/
public function getErrorOrSync($input)
{
if (!is_array($input)) {
return "Wrong input";
}
//provjera postojanja nužnih podataka
$ime = $this->ime;
if (!$ime && !isset($input['ime'])) {
return 'Ime je obvezno';
}
if (isset($input['ime'])) {
$ime = $input['ime'];
}
if (isset($input['allowed'])) {
$allowed = $input['allowed'];
} else {
$allowed = array();
}
if (!$allowed || !is_array($allowed)) {
$allowed = array();
}
//kraj provjere nužnih podataka
//provjera zauzetosti imena
$query = Role::where('ime', '=', $ime);
if ($this->id > 0) {
$query = $query->where('id', '!=', $this->id);
}
if ($query->count() > 0) {
return 'Već postoji uloga s imenom ' . $ime . '.';
}
//kraj provjere zauzetosti imena
//odabir postojećih dozvola
if (count($allowed) > 0) {
$allowed = Permission::select('id')->whereIn('id', $allowed)->get()->lists('id');
}
//pohrana podataka
$this->ime = $ime;
if (isset($input['opis'])) {
$this->opis = $input['opis'];
}
$this->save();
//pohrana dozvola
if (count($allowed) > 0) {
$this->permissions()->sync($allowed);
} else {
$this->permissions()->detach();
}
}
示例5: getById
public static function getById($id)
{
$q = Permission::select()->where('id = ?', $id);
return $q->fetch();
}