Skip to content

Commit 98c8cd0

Browse files
committed
feat: use logical and comparison expressions with Laravel's where()
1 parent 0409504 commit 98c8cd0

14 files changed

+34
-18
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,11 @@ new CondXor(string|Expression $value1, string|Expression $value2);
179179
// Examples in Aggregates::countFilter()
180180
```
181181

182-
> **Warning**
183-
> These objects can currently not be used with Laravel's `where()`.
184-
> They are only for logical operations within aggregates or as selected columns.
185-
> I am working on fixing that ;)
182+
You can use these expressions directly with Laravel's `where()` method:
183+
184+
```php
185+
BlogVistis::where(new Equal('url', new Value('/exam\'ple1')))->get()
186+
```
186187

187188
### Functions
188189

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
],
1919
"require": {
2020
"php": "^8.1",
21-
"illuminate/contracts": "^10.13.0",
22-
"illuminate/database": "^10.13.0",
21+
"illuminate/contracts": "^10.13.1",
22+
"illuminate/database": "^10.13.1",
2323
"illuminate/support": "^10.0"
2424
},
2525
"require-dev": {

src/Operator/Comparison/Between.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
namespace Tpetry\QueryExpressions\Operator\Comparison;
66

7+
use Illuminate\Contracts\Database\Query\ConditionExpression;
78
use Illuminate\Contracts\Database\Query\Expression;
89
use Illuminate\Database\Grammar;
910
use Tpetry\QueryExpressions\Concerns\StringizeExpression;
1011

11-
class Between implements Expression
12+
class Between implements ConditionExpression
1213
{
1314
use StringizeExpression;
1415

src/Operator/Comparison/DistinctFrom.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
namespace Tpetry\QueryExpressions\Operator\Comparison;
66

7+
use Illuminate\Contracts\Database\Query\ConditionExpression;
78
use Illuminate\Contracts\Database\Query\Expression;
89
use Illuminate\Database\Grammar;
910
use Tpetry\QueryExpressions\Concerns\IdentifiesDriver;
1011
use Tpetry\QueryExpressions\Concerns\StringizeExpression;
1112

12-
class DistinctFrom implements Expression
13+
class DistinctFrom implements ConditionExpression
1314
{
1415
use IdentifiesDriver;
1516
use StringizeExpression;

src/Operator/Comparison/Equal.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace Tpetry\QueryExpressions\Operator\Comparison;
66

7+
use Illuminate\Contracts\Database\Query\ConditionExpression;
78
use Tpetry\QueryExpressions\Operator\OperatorExpression;
89

9-
class Equal extends OperatorExpression
10+
class Equal extends OperatorExpression implements ConditionExpression
1011
{
1112
protected function operator(): string
1213
{

src/Operator/Comparison/GreaterThan.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace Tpetry\QueryExpressions\Operator\Comparison;
66

7+
use Illuminate\Contracts\Database\Query\ConditionExpression;
78
use Tpetry\QueryExpressions\Operator\OperatorExpression;
89

9-
class GreaterThan extends OperatorExpression
10+
class GreaterThan extends OperatorExpression implements ConditionExpression
1011
{
1112
protected function operator(): string
1213
{

src/Operator/Comparison/GreaterThanOrEqual.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace Tpetry\QueryExpressions\Operator\Comparison;
66

7+
use Illuminate\Contracts\Database\Query\ConditionExpression;
78
use Tpetry\QueryExpressions\Operator\OperatorExpression;
89

9-
class GreaterThanOrEqual extends OperatorExpression
10+
class GreaterThanOrEqual extends OperatorExpression implements ConditionExpression
1011
{
1112
protected function operator(): string
1213
{

src/Operator/Comparison/LessThan.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace Tpetry\QueryExpressions\Operator\Comparison;
66

7+
use Illuminate\Contracts\Database\Query\ConditionExpression;
78
use Tpetry\QueryExpressions\Operator\OperatorExpression;
89

9-
class LessThan extends OperatorExpression
10+
class LessThan extends OperatorExpression implements ConditionExpression
1011
{
1112
protected function operator(): string
1213
{

src/Operator/Comparison/LessThanOrEqual.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace Tpetry\QueryExpressions\Operator\Comparison;
66

7+
use Illuminate\Contracts\Database\Query\ConditionExpression;
78
use Tpetry\QueryExpressions\Operator\OperatorExpression;
89

9-
class LessThanOrEqual extends OperatorExpression
10+
class LessThanOrEqual extends OperatorExpression implements ConditionExpression
1011
{
1112
protected function operator(): string
1213
{

src/Operator/Comparison/NotDistinctFrom.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
namespace Tpetry\QueryExpressions\Operator\Comparison;
66

7+
use Illuminate\Contracts\Database\Query\ConditionExpression;
78
use Illuminate\Contracts\Database\Query\Expression;
89
use Illuminate\Database\Grammar;
910
use Tpetry\QueryExpressions\Concerns\IdentifiesDriver;
1011
use Tpetry\QueryExpressions\Concerns\StringizeExpression;
1112

12-
class NotDistinctFrom implements Expression
13+
class NotDistinctFrom implements ConditionExpression
1314
{
1415
use IdentifiesDriver;
1516
use StringizeExpression;

0 commit comments

Comments
 (0)