承接 asp-devteam/laravel-repository 相关项目开发

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

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

asp-devteam/laravel-repository

Composer 安装命令:

composer require asp-devteam/laravel-repository

包简介

Library created to provide an easy way to develop a Model's CRUD in laravel.

README 文档

README

Software License Total Downloads

This is a library created to provide an easy way to develop a Model's CRUD in laravel.
It provides several traits and classes to allow you to create Controllers that handle automaticaly pagination and create JSON responses in a standard format. Also, it provides a set of traits to implement what we call Model driven Repositories, which allows to have your Models act as data Repositories that can handle filtering, pagination, CRUD operations as well as provide an easy way to create your own custom operations and validations.

Requirements

This package requires:

  • PHP 7.2+
  • Laravel 7+ or Lumen 7+

Install

The compatibility with Laravel is as following

Laravellaravel-repository
5.7^0.1
5.8^0.1
6.x^6.0
7.x^7.0

To add dependency to a Laravel 7.x project, run

composer require asp-devteam/laravel-repository "^7.0"

Laravel

Register Service Provider

Append the following line to the providers key in config/app.php to register the package:

ASP\Repository\RepositoryServiceProvider::class,

The package supports auto-discovery, so if you use Laravel 5.5 or later you may skip registering the service provider and facades as they will be registered automatically.

Publishing resources

To publish the available translations and config to your application, for customization, just run:

php artisan vendor:publish --tag=repository.translations
php artisan vendor:publish --tag=repository.config

Usage

Write a few lines about the usage of this package.

This documentation assumes some knowledge of how Fractal works.

Extending ASP\Repository\Base\Controller

The package has a Controller class, which implements a middleware that handles pagination on index:

use ASP\Repository\Base\Controller;

class YourController extends Controller
{
}

Using Model Repository

Option 1: Using the provided Repository

To use the Repository you can use it in your model class:

use ASP\Repository\Traits\Repository;

class YourModel extends Model
{
    use Repository;
}

This will make available to you several methods:

  • getAllRecords(Filter $filters = null, array $pagination = null)
  • getRecordById($id)
  • createRecord(Request $request)
  • updateRecordById($id, Request $request)
  • deleteRecordById($id, Request $request)
Option 2: Creating your own Repository

You can also extend the Repository and add your own methods, this also allows you to use Model Validators:

use ASP\Repository\Traits\Repository;
...
trait YourRepository
{
    use Repository;


}
use ASP\Repository\Traits\Repository;

class YourModel extends Model
{
    use YourRepository, YourModelValidator;
}

Using Validators

use ASP\Repository\Traits\Validator;

trait YourModelValidator
{
    use Validator;

    /**
     * @return void
     */
    protected static function boot()
    {
        parent::boot();

        self::setBaseRules(
            [
                'name' => [
                    'laravel rules here'
                ],
            ]
        );
    }

    /**
     * @return array
     */
    protected static function getCustomRules()
    {
        $rules = self::getBaseRules();

        return array_merge(
            $rules,
            [
              'new rules'
            ]
        );
    }
}

Using Filters

To filter your Model queries you can extend ASP\Repository\Base\Filter:

use ASP\Repository\Base\Filter;

class PetFilters extends Filter
{
  public function <filterName>(<$parameters>)

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security-related issues, please email asp-devteam@alter-solutions.com instead of using the issue tracker.

License

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

Copyright 2020 Alter Solutions Portugal

asp-devteam/laravel-repository 适用场景与选型建议

asp-devteam/laravel-repository 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 447 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 09 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 asp-devteam/laravel-repository 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 asp-devteam/laravel-repository 我们能提供哪些服务?
定制开发 / 二次开发

基于 asp-devteam/laravel-repository 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-19