sukohi / json-where

2.0.0 2015-08-08 20:53 UTC

This package is not auto-updated.

Last update: 2024-09-14 18:16:15 UTC


README

一个主要用于Laravel,便于设置JSON查询条件的PHP包。
(适用于Laravel 5+。 适用于Laravel 4.2)

安装

在 composer.json 中添加此包名。

"require": {
  "sukohi/json-where": "2.*"
}

执行 composer 命令。

composer update

在 app.php 中注册服务提供者。

'providers' => [
    ...Others...,  
    Sukohi\JsonWhere\JsonWhereServiceProvider::class,
]

同样可以使用别名。

'aliases' => [
    ...Others...,  
    'JsonWhere'   => Sukohi\JsonWhere\Facades\JsonWhere::class
]

使用方法

$jsons = DB::table('tests')->where(function($query){

                \JsonWhere::query($query)
                    ->column('json')
                    ->value(3, $type = 'auto'); // $type: (default: auto), string or int. Optional.

            })->get();

或者,您也可以这样使用模型。

$jsons = \App\Test::where(function($query){

                \JsonWhere::query($query)
                    ->column('json')
                    ->value(3, 'int');
    
            })->get();

许可证

本包采用MIT许可证授权。

版权所有 2015 Sukohi Kuhoh