本文整理汇总了PHP中app\models\Permission::hasPermission方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::hasPermission方法的具体用法?PHP Permission::hasPermission怎么用?PHP Permission::hasPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Permission
的用法示例。
在下文中一共展示了Permission::hasPermission方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index($card_id = false, $camp_id = false)
{
$data['tasks'] = Task::get_tasks($card_id, $camp_id);
$data['createbtn'] = Permission::hasPermission('tasks.create');
$data['editbtn'] = Permission::hasPermission('tasks.edit');
$data['deletebtn'] = Permission::hasPermission('tasks.delete');
return view('tasks.index', $data);
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->guest() && $request->ajax()) {
return response('Unauthorized.', 401);
}
/*
|--------------------------------------------------------------------------
| Admin auth filter
|--------------------------------------------------------------------------
| You need to give your routes a name before using this filter.
| I assume you are using resource. so the route for the UsersController index method
| will be admin.users.index then the filter will look for permission on users.view
| You can provide your own rule by passing a argument to the filter
|
*/
$userRule = null;
// no special route name passed, use the current name route
if (is_null($userRule)) {
$explode = explode('.', Route::currentRouteName());
if (count($explode) < 3) {
$userRule = Route::currentRouteName();
} else {
$userRule = $explode[1] . '.' . $explode[2];
}
}
$userRule = str_replace("-", '.', $userRule);
// no access to the request page and request page not the root admin page
if (!Permission::hasPermission($userRule) && $userRule !== 'ruban.home') {
$redirect['route'] = 'ruban.home';
$redirect['with'] = 'danger';
$redirect['message'] = trans('ruban.permissions.access_denied');
} else {
if (!Permission::hasPermission($userRule) && $userRule === 'ruban.home') {
//can't see the admin home page go back to home site page
$redirect['route'] = 'auth.logout';
$redirect['with'] = 'danger';
$redirect['message'] = trans('ruban.permissions.access_denied');
}
}
if (isset($redirect['route'])) {
return Redirect::route($redirect['route'])->with($redirect['with'], $redirect['message']);
}
return $next($request);
}
示例3: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$data['dispute'] = Dispute::findOrFail($id);
$data['projects'] = Dispute::getlists(Project::get_payouts(2, 0));
$data['cancelbtn'] = Permission::hasPermission('disputes.index');
return view('disputes.edit', $data);
}
示例4: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$data['permission'] = Permission::findOrFail($id);
$data['cancelbtn'] = Permission::hasPermission('permissions.index');
return view('permissions.edit', $data);
}
示例5: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$data['group'] = $group = Group::find($id);
if ($group) {
$data['permissions'] = Permission::all();
$data['userPermissions'] = Permission::formatpermission($group->permissions);
$data['cancelbtn'] = Permission::hasPermission('groups.index');
return view('groups.edit', $data);
} else {
Session::flash('danger', Lang::get('ruban.group.notfound'));
return Redirect::route('ruban.groups.index');
}
}
示例6: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response*/
public function edit($id)
{
$data['district'] = $district = District::find($id);
if ($district) {
$data['projects'] = Project::orderby('name', 'asc')->lists('name', 'id');
$data['cancelbtn'] = Permission::hasPermission('districts.index');
return view('districts.edit', $data);
} else {
Session::flash('danger', Lang::get('ruban.district.notfound'));
return Redirect::route('ruban.districts.index');
}
}
示例7: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$data['card'] = $card = Card::find($id);
if ($card) {
$data['sectors'] = Sector::lists('name', 'id');
$data['districts'] = District::groupby($this->district)->lists($this->district, 'id');
$data['projects'] = Project::orderby('name', 'asc')->lists('name', 'id');
$data['listbtn'] = Permission::hasPermission('cards.update');
return view('cards.edit', $data);
} else {
Session::flash('danger', Lang::get('ruban.card.notfound'));
return Redirect::route('ruban.cards.index');
}
}
示例8: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$data['project'] = $project = Project::find($id);
if ($project) {
$data['sectors'] = Sector::lists('name', 'id');
$data['states'] = State::lists('state', 'id');
$data['districts'] = District::where('state_id', $data['project']->state_id)->lists('district', 'id');
$data['taluks'] = Taluk::where('district_id', $data['project']->district_id)->lists('taluk', 'id');
$data['cancelbtn'] = Permission::hasPermission('projects.index');
return view('projects.edit', $data);
} else {
Session::flash($this->danger, Lang::get('ruban.project.notfound'));
return Redirect::route('ruban.projects.index');
}
}
示例9: updateprofile
/**
* Update the profile
*
* @param int $id
* @return Response
*/
public function updateprofile($id)
{
$data['user'] = User::findOrFail($id);
$data['sectors'] = Sector::lists('name', 'id');
$data['districts'] = District::lists('district', 'id');
$districtsselected = PartnerDistrict::get_districts_selected($id);
$data['districtsselected'] = PartnerDistrict::format_selected($districtsselected);
$data['cancelbtn'] = Permission::hasPermission('users.index');
return view('users.profile', $data);
}