本文整理汇总了PHP中Illuminate\Support\Facades\Gate::allows方法的典型用法代码示例。如果您正苦于以下问题:PHP Gate::allows方法的具体用法?PHP Gate::allows怎么用?PHP Gate::allows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Gate
的用法示例。
在下文中一共展示了Gate::allows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update(Request $request, PersonModel $person)
{
$person->setName($request->input('name'))->setEnabled($request->has('enabled'));
if (Gate::allows('editSuperuser', $person)) {
$person->setSuperuser($request->has('superuser'));
}
PersonFacade::save($person);
}
示例2: __construct
public function __construct()
{
if (!Gate::allows('manage-university')) {
abort(403);
}
$this->middleware('auth');
if (auth()->check()) {
$this->university = auth()->user()->university;
}
}
示例3: compose
public function compose(View $view)
{
$view->sidebar->group(trans('global.menus.social'), function (SidebarGroup $group) {
$group->addItem(trans('reasons::global.name'), function (SidebarItem $item) {
$item->icon = config('typicms.reasons.sidebar.icon');
$item->weight = config('typicms.reasons.sidebar.weight');
$item->route('admin::index-reasons');
$item->append('admin::create-reason');
$item->authorize(Gate::allows('index-reasons'));
});
});
}
示例4: compose
public function compose(View $view)
{
$view->sidebar->group(trans('global.menus.content'), function (SidebarGroup $group) {
$group->addItem(trans('blocks::global.name'), function (SidebarItem $item) {
$item->id = 'blocks';
$item->icon = config('typicms.blocks.sidebar.icon', 'icon fa fa-fw fa-list-alt');
$item->weight = config('typicms.blocks.sidebar.weight');
$item->route('admin::index-blocks');
$item->append('admin::create-block');
$item->authorize(Gate::allows('index-blocks'));
});
});
}
示例5: compose
public function compose(View $view)
{
$view->sidebar->group(trans('global.menus.newsletter'), function (SidebarGroup $group) {
$group->id = 'newsletter';
$group->weight = 20;
$group->addItem(trans('newsletter::global.name'), function (SidebarItem $item) {
$item->icon = config('typicms.newsletter.sidebar.icon', 'icon fa fa-fw fa-envelope');
$item->weight = config('typicms.newsletter.sidebar.weight');
$item->route('admin::index-newsletter');
$item->append('admin::create-newsletter');
$item->authorize(Gate::allows('newsletter.index'));
});
});
}
示例6: compose
public function compose(View $view)
{
$view->sidebar->group(trans('global.menus.shop'), function (SidebarGroup $group) {
$group->id = 'shop';
$group->weight = 2;
$group->addItem(trans('attributes::global.name'), function (SidebarItem $item) {
$item->icon = config('typicms.attributes.sidebar.icon');
$item->weight = config('typicms.attributes.sidebar.weight');
$item->route('admin::index-attribute_groups');
$item->append('admin::create-attribute_group');
$item->authorize(Gate::allows('index-attribute_groups'));
});
});
}
示例7: index
public function index()
{
$model = new Order();
$dataGrid = DataGrid::make($model);
$dataGrid->addColumn(DataGrid::textColumn('id', 'Order ID'));
$dataGrid->addColumn(DataGrid::textColumn('shipping_method', 'Shipping Method'));
$dataGrid->addColumn(DataGrid::textColumn('payment_method', 'Payment Method'));
$dataGrid->addColumn(DataGrid::textColumn('order_status_title', 'Order Status'));
if (Gate::allows('hasPermission', [AdminUser::class, "admin.order.view"])) {
$dataGrid->addColumn(DataGrid::linkColumn('view', 'View', function ($row) {
return "<a href='" . route('admin.order.view', $row->id) . "'>View</a>";
}));
}
return view('admin.order.index')->with('dataGrid', $dataGrid);
}
示例8: compose
public function compose(View $view)
{
$view->sidebar->group('dashboard', function (SidebarGroup $group) {
$group->id = 'dashboard';
$group->weight = 10;
$group->hideHeading();
$group->addItem(trans('dashboard::global.name'), function (SidebarItem $item) {
$item->id = 'dashboard';
$item->icon = config('typicms.dashboard.sidebar.icon', 'icon fa fa-fw fa-dashboard');
$item->weight = config('typicms.dashboard.sidebar.weight');
$item->route('dashboard');
$item->authorize(Gate::allows('dashboard'));
});
});
}
示例9: registerFrontendMenu
/**
* build frontend menu and attach it to view.
*/
private function registerFrontendMenu()
{
$this->app->singleton('menu.frontend', function () {
return Menu::create('frontend');
});
View::composer('vain::app', function ($view) {
$handler = app('menu.frontend');
$view->with('menu', $handler);
// inject home item
$handler->addChild('Home')->setUri(route('index.home'))->setExtra('icon', 'home');
if (Gate::allows('app.admin.show')) {
$handler->addChild('Admin Panel')->setUri(route('user.admin.users.index'))->setExtra('icon', 'tachometer');
}
Event::fire(new FrontendMenuCreated($handler, $view));
});
}
示例10: tearDown
/**
* Teardown block setup
*/
public static function tearDown()
{
$html = ob_get_clean();
end(self::$models);
$slug = key(self::$models);
$title = array_pop(self::$models);
/** @var Block $block */
$block = Block::where('slug', $slug)->first();
if (!$block) {
$block = new Block(['slug' => $slug, 'title' => $title, 'content' => trim($html)]);
$block->save();
}
if (Gate::allows('edit-html-blocks')) {
return sprintf('<html-block slug="%s">%s</html-block>', $slug, trim($block->content));
}
return trim($block->content);
}
示例11: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$model = new TaskStatus();
$dataGrid = DataGrid::make($model);
$dataGrid->addColumn(DataGrid::textColumn('name', 'Status Name', ['sortable' => 'asc']));
if (Gate::allows('hasPermission', [AdminUser::class, "setup.task-status.edit"])) {
$dataGrid->addColumn(DataGrid::linkColumn('edit', 'Edit', function ($row) {
return "<a href='" . route('setup.task-status.edit', $row->id) . "'>Edit</a>";
}));
}
if (Gate::allows('hasPermission', [AdminUser::class, "setup.task-status.destroy"])) {
$dataGrid->addColumn(DataGrid::linkColumn('destroy', 'Destroy', function ($row) {
return "<form method='post' action='" . route('setup.task-status.destroy', $row->id) . "'>" . "<input type='hidden' name='_method' value='delete'/>" . csrf_field() . '<a href="#" onclick="jQuery(this).parents(\'form:first\').submit()">Destroy</a>' . "</form>";
}));
}
return view('setup.task-status.index')->with('dataGrid', $dataGrid);
}
示例12: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$role = new Role();
$dataGrid = DataGrid::make($role);
$dataGrid->addColumn(DataGrid::textColumn('name', 'Role Name'));
$dataGrid->addColumn(DataGrid::textColumn('description', 'Role Description'));
if (Gate::allows('hasPermission', [AdminUser::class, "admin.role.edit"])) {
$dataGrid->addColumn(DataGrid::linkColumn('edit', 'Edit', function ($row) {
return "<a href='" . route('admin.role.edit', $row->id) . "'>Edit</a>";
}));
}
if (Gate::allows('hasPermission', [AdminUser::class, "admin.role.edit"])) {
$dataGrid->addColumn(DataGrid::linkColumn('destroy', 'Destroy', function ($row) {
return "<form method='post' action='" . route('admin.role.destroy', $row->id) . "'>" . "<input type='hidden' name='_method' value='delete'/>" . csrf_field() . '<a href="#" onclick="jQuery(this).parents(\'form:first\').submit()">Destroy</a>' . "</form>";
}));
}
return view('admin.user.role.index')->with('dataGrid', $dataGrid);
}
示例13: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$model = new OrderStatus();
$dataGrid = DataGrid::make($model);
$dataGrid->addColumn(DataGrid::textColumn('id', 'Order ID'));
$dataGrid->addColumn(DataGrid::textColumn('title', 'Title'));
$dataGrid->addColumn(DataGrid::textColumn('is_default', 'Is Default'));
$dataGrid->addColumn(DataGrid::textColumn('is_last_stage', 'Is Last Stage'));
if (Gate::allows('hasPermission', [AdminUser::class, "admin.order-status.edit"])) {
$dataGrid->addColumn(DataGrid::linkColumn('edit', 'Edit', function ($row) {
return "<a href='" . route('admin.order-status.edit', $row->id) . "'>Edit</a>";
}));
}
if (Gate::allows('hasPermission', [AdminUser::class, "admin.order-status.destroy"])) {
$dataGrid->addColumn(DataGrid::linkColumn('destroy', 'Destroy', function ($row) {
return "<form method='post' action='" . route('admin.order-status.destroy', $row->id) . "'>" . "<input type='hidden' name='_method' value='delete'/>" . csrf_field() . '<a href="#" onclick="jQuery(this).parents(\'form:first\').submit()">Destroy</a>' . "</form>";
}));
}
return view('admin.order-status.index')->with('dataGrid', $dataGrid);
}
示例14: table
/**
* Returns a table of all labels.
*
* @param Label $label
*
* @return \Orchestra\Contracts\Html\Builder
*/
public function table(Label $label)
{
return $this->table->of('labels', function (TableGrid $table) use($label) {
$table->with($label)->paginate($this->perPage);
$table->sortable(['name']);
$table->column('name', function (Column $column) {
$column->label = 'Label';
$column->value = function (Label $label) {
return $label->display_large;
};
});
$table->column('issues', function (Column $column) {
$column->label = 'Open Issues';
$column->headers = ['class' => 'hidden-xs'];
$column->value = function (Label $label) {
return $label->issues()->open()->count();
};
$column->attributes = function () {
return ['class' => 'hidden-xs'];
};
});
// Check if the current user has access to edit
// labels before rendering the label as a link.
if (Gate::allows('labels.edit')) {
$table->column('edit', function (Column $column) {
$column->value = function (Label $label) {
return link_to_route('labels.edit', 'Edit', [$label->id], ['class' => 'btn btn-xs btn-warning']);
};
});
}
// Check if the current user has access to delete
// labels before rendering the delete column.
if (Gate::allows('labels.destroy')) {
$table->column('delete', function (Column $column) {
$column->value = function (Label $label) {
return link_to_route('labels.destroy', 'Delete', [$label->id], ['data-post' => 'DELETE', 'data-title' => 'Delete Label?', 'data-message' => 'Are you sure you want to delete this label?', 'class' => 'btn btn-xs btn-danger']);
};
});
}
});
}
示例15: index
public function index()
{
$model = new Review();
$dataGrid = DataGrid::make($model);
$dataGrid->addColumn(DataGrid::textColumn('id', 'Id'));
$dataGrid->addColumn(DataGrid::textColumn('user_name', 'User Name'));
$dataGrid->addColumn(DataGrid::textColumn('product_title', 'Product Title'));
$dataGrid->addColumn(DataGrid::textColumn('star', 'Product Title'));
$dataGrid->addColumn(DataGrid::textColumn('status', 'Status'));
if (Gate::allows('hasPermission', [AdminUser::class, "admin.review.edit"])) {
$dataGrid->addColumn(DataGrid::linkColumn('edit', 'Edit', function ($row) {
return "<a href='" . route('admin.review.edit', $row->id) . "'>Edit</a>";
}));
}
if (Gate::allows('hasPermission', [AdminUser::class, "admin.review.destroy"])) {
$dataGrid->addColumn(DataGrid::linkColumn('destroy', 'Destroy', function ($row) {
return "<form method='post' action='" . route('admin.review.destroy', $row->id) . "'>" . "<input type='hidden' name='_method' value='delete'/>" . csrf_field() . '<a href="#" onclick="jQuery(this).parents(\'form:first\').submit()">Destroy</a>' . "</form>";
}));
}
return view('admin.review.index')->with('dataGrid', $dataGrid);
}