Skip to content

Commit f568973

Browse files
committed
model conversions for L9 and L8
1 parent c7cfd3a commit f568973

File tree

4 files changed

+66
-26
lines changed

4 files changed

+66
-26
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
"license": "MIT",
2020
"require": {
2121
"php": "^8.1",
22-
"illuminate/support": "^9.0|^10.0|^11.0",
23-
"illuminate/container": "^9.0|^10.0|^11.0",
24-
"illuminate/database": "^9.0|^10.0|^11.0",
25-
"illuminate/events": "^9.0|^10.0|^11.0",
22+
"illuminate/support": "^8.0|^9.0",
23+
"illuminate/container": "^8.0|^9.0",
24+
"illuminate/database": "^8.0|^9.0",
25+
"illuminate/events": "^8.0|^9.0",
2626
"opensearch-project/opensearch-php": "^2.2"
2727
},
2828
"require-dev": {

src/Eloquent/Builder.php

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,43 @@ class Builder extends BaseEloquentBuilder
1919
* @var array
2020
*/
2121
protected $passthru = [
22-
22+
'aggregate',
2323
'average',
2424
'avg',
2525
'count',
2626
'dd',
27-
'doesntexist',
27+
'doesntExist',
28+
'doesntExistOr',
2829
'dump',
2930
'exists',
30-
'getbindings',
31-
'getconnection',
32-
'getgrammar',
31+
'existsOr',
32+
'explain',
33+
'getBindings',
34+
'getConnection',
35+
'getGrammar',
36+
'implode',
3337
'insert',
34-
'insertgetid',
35-
'insertorignore',
36-
'insertusing',
38+
'insertGetId',
39+
'insertOrIgnore',
40+
'insertUsing',
3741
'max',
3842
'min',
39-
'pluck',
40-
'pull',
41-
'push',
4243
'raw',
44+
'rawValue',
4345
'sum',
4446
'toSql',
4547
//ES only:
4648
'matrix',
4749
'query',
48-
'rawsearch',
49-
'rawaggregation',
50-
'getindexsettings',
51-
'getindexmappings',
52-
'deleteindexifexists',
53-
'deleteindex',
50+
'rawSearch',
51+
'rawAggregation',
52+
'getIndexSettings',
53+
'getIndexMappings',
54+
'deleteIndexIfExists',
55+
'deleteIndex',
5456
'truncate',
55-
'indexexists',
56-
'createindex',
57+
'indexExists',
58+
'createIndex',
5759
'search',
5860
];
5961

@@ -196,6 +198,8 @@ public function chunkById($count, callable $callback, $column = '_id', $alias =
196198

197199
if ($column === '_id') {
198200
//Use PIT
201+
202+
199203
return $this->_chunkByPit($count, $callback, $keepAlive);
200204
} else {
201205
$lastId = null;
@@ -230,14 +234,13 @@ public function chunkById($count, callable $callback, $column = '_id', $alias =
230234

231235

232236
}
233-
//
234-
//
237+
238+
235239
// public function chunk($count, callable $callback, $keepAlive = '5m')
236240
// {
237241
// //default to using PIT
238242
// return $this->_chunkByPit($count, $callback, $keepAlive);
239243
// }
240-
//
241244

242245

243246
//----------------------------------------------------------------------

src/Eloquent/HybridRelations.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
/**
3+
* @credit https://github.com/jenssegers/laravel-mongodb/
4+
*/
25

36
namespace PDPhilip\OpenSearch\Eloquent;
47

src/Query/Builder.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,40 @@ public function whereTimestamp($column, $operator = null, $value = null, $boolea
404404
}
405405

406406

407+
// Adding whereNot() from Laravel 9 nas is as it's not native to Laravel 8
408+
409+
/**
410+
* @param $column
411+
* @param $value
412+
*
413+
* @return Builder
414+
*/
415+
public function whereNot($column, $operator = null, $value = null, $boolean = 'and')
416+
{
417+
if (is_array($column)) {
418+
return $this->whereNested(function ($query) use ($column, $operator, $value, $boolean) {
419+
$query->where($column, $operator, $value, $boolean);
420+
}, $boolean.' not');
421+
}
422+
423+
return $this->where($column, $operator, $value, $boolean.' not');
424+
}
425+
426+
/**
427+
* Add an "or where not" clause to the query.
428+
*
429+
* @param \Closure|string|array $column
430+
* @param mixed $operator
431+
* @param mixed $value
432+
*
433+
* @return $this
434+
*/
435+
public function orWhereNot($column, $operator = null, $value = null)
436+
{
437+
return $this->whereNot($column, $operator, $value, 'or');
438+
}
439+
440+
407441
//----------------------------------------------------------------------
408442
// Query Processing (Connection API)
409443
//----------------------------------------------------------------------

0 commit comments

Comments
 (0)