-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
f120505
commit 0fe4e37
Showing
7 changed files
with
64 additions
and
11 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
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
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
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
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
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,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Dex\Laravel\Anything\Models\Builders; | ||
|
||
use Dex\Laravel\Anything\Models\Anything; | ||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
/** | ||
* @extends Builder<Anything> | ||
*/ | ||
class AnythingBuilder extends Builder | ||
{ | ||
public function whereSearch(string $search): self | ||
{ | ||
$likeOperator = ($temp = config('anything.search.operator')) && is_string($temp) ? $temp : null; | ||
|
||
return $this->when($search, function ($q) use ($search, $likeOperator) { | ||
$q->whereAny([ | ||
'label', | ||
'slug', | ||
], $likeOperator, '%' . $search . '%'); | ||
}); | ||
} | ||
|
||
public function whereType(string $type): self | ||
{ | ||
return $this->where('type', $type); | ||
} | ||
|
||
public function whereSlug(string $slug): self | ||
{ | ||
return $this->where('slug', $slug); | ||
} | ||
} |
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