承接 syntech/globalscopes 相关项目开发

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

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

syntech/globalscopes

最新稳定版本:2.0.1

Composer 安装命令:

composer require syntech/globalscopes

包简介

A Laravel package to add general model scopes to all models

README 文档

README

A Laravel package for adding global model scopes and attributes without modifying individual models.

Installation

You can install the package via Composer:

composer require syntech/globalscopes

Configuration

Publish the configuration file:

php artisan vendor:publish --provider="Syntech\GlobalScopes\GlobalScopesServiceProvider"

This will create a globalscopes.php configuration file in the config directory of your Laravel application.

Example Configuration

return [

       /*
    |--------------------------------------------------------------------------
    | Global Query Methods
    |--------------------------------------------------------------------------
    |
    | Define any global query methods that should be available across all
    | Eloquent models. These methods can be used to add commonly used query
    | functionality to all models.
    |
    | Example:
    | 'active' => function () {
    |    return $this->where('status', 1);
    | },
    |
    */

    'methods' => [
        'active' => function () {
            return $this->where('status', 1);
        },
        'someMore' => function () {
                    // add more ...
            }
    ],

];

Usage

Adding Global Scopes

Once configured, the global scopes will automatically be applied to all Eloquent models. Adding Global Attributes

Global attributes can be accessed as if they are defined directly on the model:

$customers = Customer::active()->get();

return $customers; // Uses the global attribute logic

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固