定制 lomkit/laravel-access-control 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lomkit/laravel-access-control

最新稳定版本:v0.3.2

Composer 安装命令:

composer require lomkit/laravel-access-control

包简介

A package to help you manage your laravel application access rights.

README 文档

README

Social Card of Laravel Access Control

Laravel Access Control

Laravel Access Control allows you to fully secure your application in two key areas: Policies and Queries. Manage everything in one place!

Requirements

PHP 8.2+ and Laravel 11+

Documentation, Installation, and Usage Instructions

See the documentation for detailed installation and usage instructions.

What it does

You first need to define the perimeters concerned by your applications.

Create the model control:

class PostControl extends Control { protected function perimeters(): array { return [ GlobalPerimeter::new() ->allowed(function (Model $user, string $method) { return $user->can(sprintf('%s global models', $method)); }) ->should(function (Model $user, Model $model) { return true; }) ->query(function (Builder $query, Model $user) { return $query; }), ClientPerimeter::new() ->allowed(function (Model $user, string $method) { return $user->can(sprintf('%s client models', $method)); }) ->should(function (Model $user, Model $model) { return $model->client()->is($user->client); }) ->query(function (Builder $query, Model $user) { return $query->where('client_id', $user->client->getKey()); }), // ...

Specify the control in your model:

class Post extends Model { use HasControl; }

Then set up your policy:

class PostPolicy extends ControlledPolicy { protected string $model = Post::class; }

and you are ready to go !

App\Models\Post::controlled()->get() // Apply the Control to the query $user->can('view', App\Models\Post::first()) // Check if the user can view the post according to the policy

统计信息

  • 总下载量: 5.44k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固