定制 think.studio/laravel-restricted-access 二次开发

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

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

think.studio/laravel-restricted-access

最新稳定版本:1.2.0

Composer 安装命令:

composer require think.studio/laravel-restricted-access

包简介

Restrict access to any entities or pages, or create share links.

README 文档

README

Packagist License Packagist Version Total Downloads Build Status Code Coverage Scrutinizer Code Quality

Restrict access for pages, with pin code, email or name.

Installation

Install the package via composer:

composer require think.studio/laravel-restricted-access

Optionally you can publish the config file with:

php artisan vendor:publish --provider="LinkRestrictedAccess\ServiceProvider" --tag="config"

If you want change tables names or routes, you can do it via config file.

Run migrations:

php artisan migrate

Usage

Use trait HasRestrictedLink for model

class File extends Model 
{
    use \LinkRestrictedAccess\Models\HasRestrictedLink;
}

Then you can create link

/** @var RestrictedLink $shareLink */
$shareLink = $file->restrictedLinks()->make([
    'name'         => $request->input('name'),
    'pin'          => $request->input('pin'),
    'check_pin'    => $request->boolean('check_pin'),
    'check_name'   => $request->boolean('check_name'),
    'check_email'  => $request->boolean('check_email'),
]);

if ($user = $request->user()) {
    $shareLink->meta->toMorph('creator', $user);
}

$shareLink->save();

Example check verification.

if($shareUuid = $request->string('share')) {

    $sharedLink = \LinkRestrictedAccess\RestrictedAccess::restrictedLinkModel()::query()->byKey($shareUuid)->firstOrFail();

    if ($sharedLink->needVerification() && !$sharedLink->verifiedOpenActionFromCookie($request)) {
        return // display verification view
    }

    return $sharedLink->linkable;
}

To verify access you can use routes restricted-access-link.check-pin and restricted-access-link.open-document

Credits

  • Think Studio

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-18