-
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
Showing
262 changed files
with
8,666 additions
and
1,083 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace App\Casts; | ||
|
||
use App\Enums\MetadataType; | ||
use Illuminate\Contracts\Database\Eloquent\CastsAttributes; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class MetadataValue implements CastsAttributes | ||
{ | ||
/** | ||
* Cast the given value. | ||
* | ||
* @param Model $model | ||
* @param string $key | ||
* @param mixed $value | ||
* @param array $attributes | ||
* | ||
* @return mixed | ||
*/ | ||
public function get($model, string $key, $value, array $attributes): mixed | ||
{ | ||
return match ($model->value_type->value) { | ||
MetadataType::BOOLEAN => (bool) $value, | ||
MetadataType::NUMBER => (float) $value, | ||
default => $value | ||
}; | ||
} | ||
|
||
/** | ||
* Prepare the given value for storage. | ||
* | ||
* @param Model $model | ||
* @param string $key | ||
* @param mixed $value | ||
* @param array $attributes | ||
* | ||
* @return mixed | ||
*/ | ||
public function set($model, string $key, $value, array $attributes) | ||
{ | ||
return $value; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
app/SearchTypes/DiscountSearch.php → app/Criteria/DiscountSearch.php
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,35 @@ | ||
<?php | ||
|
||
namespace App\Criteria; | ||
|
||
use App\Traits\PermissionUtility; | ||
use Heseya\Searchable\Criteria\Criterion; | ||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
class MetadataPrivateSearch extends Criterion | ||
{ | ||
use PermissionUtility; | ||
|
||
public function query(Builder $query): Builder | ||
{ | ||
if ($this->deniesAbilityByModel('show_metadata_private', $query->getModel())) { | ||
return $query; | ||
} | ||
|
||
return $query->where(function (Builder $query): void { | ||
$query->whereHas('metadataPrivate', function (Builder $query): void { | ||
$first = true; | ||
foreach ($this->value as $key => $value) { | ||
if ($first) { | ||
$query->where('name', 'LIKE', "%${key}%") | ||
->where('value', 'LIKE', "%${value}%"); | ||
$first = false; | ||
} else { | ||
$query->orWhere('name', 'LIKE', "%${key}%") | ||
->where('value', 'LIKE', "%${value}%"); | ||
} | ||
} | ||
}); | ||
}); | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
namespace App\Criteria; | ||
|
||
use Heseya\Searchable\Criteria\Criterion; | ||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
class MetadataSearch extends Criterion | ||
{ | ||
public function makeQuery(Builder $query, string $relation): Builder | ||
{ | ||
foreach ($this->value as $key => $value) { | ||
$query->whereHas($relation, function (Builder $query) use ($key, $value): void { | ||
$query->where('name', '=', $key) | ||
->where('value', '=', $value); | ||
}); | ||
} | ||
|
||
return $query; | ||
} | ||
|
||
public function query(Builder $query): Builder | ||
{ | ||
return $this->makeQuery($query, 'metadata'); | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
app/SearchTypes/OrderSearch.php → app/Criteria/OrderSearch.php
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
6 changes: 3 additions & 3 deletions
6
app/SearchTypes/PermissionSearch.php → app/Criteria/PermissionSearch.php
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
6 changes: 3 additions & 3 deletions
6
app/SearchTypes/ProductSetSearch.php → app/Criteria/ProductSetSearch.php
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
6 changes: 3 additions & 3 deletions
6
app/SearchTypes/RoleAssignableSearch.php → app/Criteria/RoleAssignableSearch.php
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
6 changes: 3 additions & 3 deletions
6
app/SearchTypes/SchemaSearch.php → app/Criteria/SchemaSearch.php
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
6 changes: 3 additions & 3 deletions
6
app/SearchTypes/WhereBelongsToManyById.php → app/Criteria/WhereBelongsToManyById.php
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
6 changes: 3 additions & 3 deletions
6
app/SearchTypes/WhereBelongsToSet.php → app/Criteria/WhereBelongsToSet.php
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
6 changes: 3 additions & 3 deletions
6
app/SearchTypes/WhereCreatedAfter.php → app/Criteria/WhereCreatedAfter.php
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
6 changes: 3 additions & 3 deletions
6
app/SearchTypes/WhereCreatedBefore.php → app/Criteria/WhereCreatedBefore.php
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
6 changes: 3 additions & 3 deletions
6
app/SearchTypes/WhereHasSlug.php → app/Criteria/WhereHasSlug.php
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,22 @@ | ||
<?php | ||
|
||
namespace App\Criteria; | ||
|
||
use Heseya\Searchable\Criteria\Criterion; | ||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
class WhereHasStatusHidden extends Criterion | ||
{ | ||
public function query(Builder $query): Builder | ||
{ | ||
return $query->where(function (Builder $query): void { | ||
$query->whereHas('status', function (Builder $query) { | ||
return $query->where('hidden', $this->value); | ||
}); | ||
|
||
if (!$this->value) { | ||
$query->orWhereDoesntHave('status'); | ||
} | ||
}); | ||
} | ||
} |
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
Oops, something went wrong.