-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
huangbule
committed
Mar 13, 2024
1 parent
42d8d8b
commit 8bd093f
Showing
17 changed files
with
456 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = false | ||
|
||
[*.{vue,js,scss}] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
* text=auto | ||
|
||
/tests export-ignore | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
.scrutinizer.yml export-ignore | ||
.travis.yml export-ignore | ||
phpunit.php export-ignore | ||
phpunit.xml.dist export-ignore | ||
phpunit.xml export-ignore | ||
.php_cs export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.idea | ||
*.DS_Store | ||
/vendor | ||
/coverage | ||
sftp-config.json | ||
composer.lock | ||
.subsplit | ||
.php_cs.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
$header = <<<EOF | ||
This file is part of the huangbule/laravel-eloquent-filter. | ||
(c) huangbule <[email protected]> | ||
This source file is subject to the MIT license that is bundled. | ||
EOF; | ||
|
||
return PhpCsFixer\Config::create() | ||
->setRiskyAllowed(true) | ||
->setRules(array( | ||
'@Symfony' => true, | ||
'header_comment' => array('header' => $header), | ||
'array_syntax' => array('syntax' => 'short'), | ||
'ordered_imports' => true, | ||
'no_useless_else' => true, | ||
'no_useless_return' => true, | ||
'php_unit_construct' => true, | ||
'php_unit_strict' => true, | ||
)) | ||
->setFinder( | ||
PhpCsFixer\Finder::create() | ||
->exclude('vendor') | ||
->in(__DIR__) | ||
) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<h1 align="center"> laravel-eloquent-filter </h1> | ||
|
||
<p align="center"> An Eloquent way to filter Eloquent Models.</p> | ||
|
||
|
||
## Installing | ||
|
||
```shell | ||
$ composer require huangbule/laravel-eloquent-filter -vvv | ||
``` | ||
|
||
## Usage | ||
|
||
TODO | ||
|
||
## Contributing | ||
|
||
You can contribute in one of three ways: | ||
|
||
1. File bug reports using the [issue tracker](https://github.com/huangbule/laravel-eloquent-filter/issues). | ||
2. Answer questions or fix bugs on the [issue tracker](https://github.com/huangbule/laravel-eloquent-filter/issues). | ||
3. Contribute new features or update the wiki. | ||
|
||
_The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable._ | ||
|
||
## License | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "huangbule/laravel-eloquent-filter", | ||
"description": "An Eloquent way to filter Eloquent Models", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "huangbule", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": {}, | ||
"autoload": { | ||
"psr-4": { | ||
"Huangbule\\LaravelEloquentFilter\\": "src" | ||
} | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Huangbule\\LaravelEloquentFilter\\EloquentFilterProvider" | ||
], | ||
"aliases": { | ||
|
||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
return [ | ||
'default' => '$like', | ||
|
||
'rule' => [ | ||
'uuid' => 'uuid|$eq', | ||
'department_name' => '#department', | ||
] | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false"> | ||
<testsuites> | ||
<testsuite name="Application Test Suite"> | ||
<directory>./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src/</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
namespace Huangbule\LaravelEloquentFilter\Contracts; | ||
|
||
interface Ipreprocess { | ||
|
||
public function handle($column, &$param); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
namespace Huangbule\LaravelEloquentFilter; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
class EloquentFilterProvider extends ServiceProvider { | ||
|
||
|
||
/** | ||
* Register the service provider. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->mergeConfigFrom(__DIR__.'/../config/filter.php', 'filter'); | ||
} | ||
|
||
public function boot() | ||
{ | ||
if ($this->app->runningInConsole()) { | ||
$this->publishes([ | ||
__DIR__.'/../config/filter.php' => config_path('filter.php'), | ||
], 'filter'); | ||
|
||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Huangbule\LaravelEloquentFilter\Exceptions; | ||
|
||
class InvalidArgumentException extends \Exception | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Huangbule\LaravelEloquentFilter\Exceptions; | ||
|
||
class NotFoundException extends \Exception | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Huangbule\LaravelEloquentFilter\Exceptions; | ||
|
||
class NotInstanceOfInterfaceException extends \Exception | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Huangbule\LaravelEloquentFilter\Preprocess; | ||
|
||
use Huangbule\LaravelEloquentFilter\Contracts\Ipreprocess; | ||
|
||
class HalfOpenDatePreprocess implements Ipreprocess { | ||
|
||
public function handle($column, &$param) { | ||
if (! empty($param[$column])) { | ||
if (is_array($param[$column])) { | ||
$start_at = $param[$column][0]; | ||
$end_at = date('Y-m-d', strtotime('+1 day', strtotime($param[$column][1]))); | ||
} else { | ||
$start_at = $param[$column]; | ||
$end_at = date('Y-m-d', strtotime('+1 day', strtotime($param[$column]))); | ||
} | ||
$param[$column] = [$start_at, $end_at]; | ||
} | ||
} | ||
} |
Oops, something went wrong.