承接 akr4m/scoping 相关项目开发

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

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

akr4m/scoping

Composer 安装命令:

composer require akr4m/scoping

包简介

This scopes allow you to add constraints to all queries for a given model. Filter your data easily.

README 文档

README

This scopes allow you to add constraints to all queries for a given model. Filter your data easily.

Installation

Simply add the package to your composer.json file and run composer update.

composer require akr4m/scoping

Usage

Add the trait to your model and your search rules.

use akr4m\scoping\Traits\CanBeScoped;

class Post extends Model
{
    use CanBeScoped;
}

Add scopes in abcController.php like this

public function __invoke(Request $request)
{
    $posts  = App\Post::withScopes($this->scopes())->get();
}

protected function scopes()
{
    return [
        // Must declare the `Scope` files
        'topic' => new TopicScope(),
        'month' => new MonthScope(),
        'year' => new YearScope(),
    ];
}

TopicScope.php file would be like this

use akr4m\scoping\Scoping\Contracts\Scope;
use Illuminate\Database\Eloquent\Builder;

class TopicScope implements Scope
{
    public function apply(Builder $builder, $value)
    {
        return $builder
            ->whereHas('topics', function ($builder) use ($topic) {
                $builder->where('slug', $value);
            });
    }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固