-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from GeoSot/gs/add-metable-interface
Add an optional `Metable` interface
- Loading branch information
Showing
2 changed files
with
52 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
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,51 @@ | ||
<?php | ||
|
||
namespace Plank\Metable; | ||
|
||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Database\Eloquent\Relations\MorphMany; | ||
use Illuminate\Support\Collection; | ||
use Plank\Metable\Meta; | ||
|
||
/** | ||
* @method static Builder whereHasMeta($key): void | ||
* @method static Builder whereDoesntHaveMeta($key) | ||
* @method static Builder whereHasMetaKeys(array $keys) | ||
* @method static Builder whereMeta(string $key, $operator, $value = null) | ||
* @method static Builder whereMetaNumeric(string $key, string $operator, $value) | ||
* @method static Builder whereMetaIn(string $key, array $values) | ||
* @method static Builder orderByMeta(string $key, string $direction = 'asc', $strict = false) | ||
* @method static Builder orderByMetaNumeric(string $key, string $direction = 'asc', $strict = false) | ||
*/ | ||
interface MetableInterface | ||
{ | ||
public function meta(): MorphMany; | ||
|
||
public function setMeta(string $key, mixed $value): void; | ||
|
||
public function setManyMeta(array $metaDictionary): void; | ||
|
||
public function syncMeta(iterable $array): void; | ||
|
||
/** | ||
* @param string $key | ||
* @param mixed $default | ||
* @return mixed | ||
*/ | ||
public function getMeta(string $key, mixed $default = null); | ||
|
||
/** | ||
* @return Collection<array-key, mixed> | ||
*/ | ||
public function getAllMeta(): Collection; | ||
|
||
public function hasMeta(string $key): bool; | ||
|
||
public function removeMeta(string $key): void; | ||
|
||
public function removeManyMeta(array $keys): void; | ||
|
||
public function purgeMeta(): void; | ||
|
||
public function getMetaRecord(string $key): ?Meta; | ||
} |