2017 © Pedro Peláez
 

library general-db

database CRUD

image

dongm2ez/general-db

database CRUD

  • Friday, June 1, 2018
  • by dongm2ez
  • Repository
  • 1 Watchers
  • 0 Stars
  • 51 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 325 % Grown

The README.md

Laravel general-db

:heart: This package helps you smiple CRUD, (*1)

Latest Stable Version Latest Unstable Version Total Downloads License , (*2)

Requirement

  • PHP >= 7.0

Installation

$ composer require dongm2ez/general-db

After installing the library, register the Dongm2ez\Db\DbServiceProvider in your config/app.php file:, (*3)

php 'providers' => [ // Other service providers... Dongm2ez\Db\DbServiceProvider::class, ],, (*4)

As optional if you want to modify the default configuration, you can publish the configuration file:, (*5)


$ php artisan vendor:publish --provider='Dongm2ez\Db\DbServiceProvider' --tag="config"

Usage


<?php namespace App\Repositories; class ExampleRepository extends \Dongm2ez\Db\AbstractRepository { protected function init() { $this->model = new ExampleModel(); } }
<?php

namespace App\Services;

class ExampleService extends \Dongm2ez\Db\AbstractService
{
    public function getAllList($params)
    {
        $extends = $this->listParamsFormat($params);
        $input = $this->listFillableFromArray($params, [
            'id',
            'user_id',
            'create_at',
            'update_at',
        ]);

        $result = (new \App\Repositories\ExampleRepository())->getList(array_merge($input, ['_extends' => $extends]));

        return $result;
    }
}

<?php

namespace App\Http\Controller;


class ExampleController extends Controller
{
    public function lists(Request $request)
    {
        $masterData = (new \App\Services\ExampleService)->getAllList($request->all());
    }
}

传值格式

字段{条件}=值, (*6)

条件不传默认为 = 查询, (*7)

例子:, (*8)

id{!}=1,意思为取 id 不等于1的所有, (*9)

支持查询条件

一元查询

{>} 大于,?pay_money{>}=100, (*10)

{ge} 大于等于, ?pay_money{ge}=100, (*11)

{<} 小于, ?pay_money{<}=100, (*12)

{le} 小于等于, ?pay_money{le}=100, (*13)

{!} 不等于, ?pay_money{!}=100, (*14)

{~} like 查询, ?pay_money{~}=100, (*15)

{!~} not like 查询, ?pay_money{!~}=100, (*16)

{#} is null 查询, ?delete_at{#}=null,表示delete_at is null, (*17)

{!#} is not null 查询, ?delete_at{!#}=null,表示delete_at is not null), (*18)

二元查询

{<>} between 查询, ?create_date{<>}=2017-10-01,2017-10-02,表示create_date between(2017-10-01,2017-10-02), (*19)

{><} not between 查询, ?create_date{><}=2017-10-01,2017-10-02,表示create_date not between(2017-10-01,2017-10-02), (*20)

多元查询

订单合单类型在做 {@}{!@} 查询时使用 ** 表示中间连接符,如 goods,event**goods 表示查询商品与活动和商品合单, (*21)

{@} in 查询, ?id{@}=1,2,3,4,表示id IN(1,2,3,4), (*22)

{!@} not in 查询, ?id{!@}=1,2,3,4,表示id IN(1,2,3,4), (*23)

扩展条件

_page 页码,默认1, (*24)

_limit 分页大小,默认15, (*25)

_sort 排序字段,默认id, (*26)

_order 排序方式,默认DESC, (*27)

_group 分组字段,默认空, (*28)

_fields 查询字段,默认 *, (*29)

_type 查询类型,列表默认 page 分页,可选 offset 方式, (*30)

_version 版本,默认 V1, (*31)

用法:, (*32)

?_type=offset&_page=200&_limit=10 偏移量模式,_page 是偏移量,_limit 是取多少, (*33)

License

MIT, (*34)

The Versions

01/06 2018

dev-master

9999999-dev

database CRUD

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar dongm2ez

01/06 2018

0.1.1

0.1.1.0

database CRUD

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar dongm2ez

31/05 2018

0.1.0

0.1.0.0

database CRUD

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar dongm2ez

31/05 2018

dev-develop

dev-develop

database CRUD

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar dongm2ez

31/05 2018

0.0.5

0.0.5.0

database CRUD

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar dongm2ez

23/05 2018

0.0.4

0.0.4.0

database CRUD

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar dongm2ez

06/03 2018

0.0.3

0.0.3.0

database CRUD

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar dongm2ez

05/03 2018

0.0.2

0.0.2.0

database CRUD

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar dongm2ez

16/01 2018

0.0.1

0.0.1.0

database CRUD

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar dongm2ez