承接 yuriy-martini/laravel-authorization 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

yuriy-martini/laravel-authorization

最新稳定版本:v0.1.1

Composer 安装命令:

composer require yuriy-martini/laravel-authorization

包简介

README 文档

README

Latest Version MIT License

Laravel Authorization

https://laravel.com/docs/master/authorization#introduction

Installation

composer require yuriy-martini/laravel-authorization

Usage

https://laravel.com/docs/master/authorization#authorizing-actions-using-policies

  1. Authorizable (User)
  2. Config
  3. Policies

U/ Authorizable

U/ A/ Example

-+ app/Models/User.php:

<?php

namespace App\Models;

class User
    implements \YuriyMartini\Laravel\Authorization\Contracts\Authorizable
{
    use \YuriyMartini\Laravel\Authorization\Concerns\Authorizable;
}

U/ Config

U/ C/ Defaults

php artisan vendor:publish --tag=authorization-defaults-config

U/ C/ Models

php artisan vendor:publish --tag=authorization-models-config

U/ C/ M/ Example

+ config/authorization/models.php:

<?php

return [
    \App\Models\User::class => [
        \App\Models\User::class => [
            YuriyMartini\Laravel\Authorization\Enums\Permission::view,
        ],
    ],
];

U/ Models

U/ M/ Example

+ app/Models/User/Authorizations.php:

<?php

namespace App\Models\User;

trait Authorizations
{
    public function isViewable(Authorizable $user): bool
    {
        return true; // here: ur BL
    }

    public function isUpdatable(Authorizable $user): bool
    {
        return true; // here: ur BL
    }

    public function isDeletable(Authorizable $user): bool
    {
        return true; // here: ur BL
    }

    public function isRestorable(Authorizable $user): bool
    {
        return true; // here: ur BL
    }

    public function isForceDeletable(Authorizable $user): bool
    {
        return true; // here: ur BL
    }
}

-+ app/Models/User.php:

<?php

namespace App\Models;

class User
    implements \YuriyMartini\Laravel\Authorization\Contracts\Model
{
    use \App\Models\User\Authorizations;
}

U/ Policies

https://laravel.com/docs/master/authorization#generating-policies

U/ P/ Example

-+ app/Policies/UserPolicy.php:

<?php
 
namespace App\Policies;
 
class UserPolicy
    extends \YuriyMartini\Laravel\Authorization\Policy
{
    protected static function getModel(): string
    {
        return \App\Models\User::class;
    }
}

Changelog

Please see Changelog File for more information on what has changed recently.

Testing

composer test

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-10-16