Path: blob/1.0-develop/app/Contracts/Repository/RepositoryInterface.php
10279 views
<?php12namespace Pterodactyl\Contracts\Repository;34use Illuminate\Support\Collection;5use Illuminate\Database\Eloquent\Model;6use Illuminate\Database\Eloquent\Builder;7use Illuminate\Contracts\Pagination\LengthAwarePaginator;89interface RepositoryInterface10{11/**12* Return an identifier or Model object to be used by the repository.13*/14public function model(): string;1516/**17* Return the model being used for this repository instance.18*/19public function getModel(): Model;2021/**22* Returns an instance of a query builder.23*/24public function getBuilder(): Builder;2526/**27* Returns the columns to be selected or returned by the query.28*/29public function getColumns(): array;3031/**32* An array of columns to filter the response by.33*/34public function setColumns(array|string $columns = ['*']): self;3536/**37* Stop repository update functions from returning a fresh38* model when changes are committed.39*/40public function withoutFreshModel(): self;4142/**43* Return a fresh model with a repository updates a model.44*/45public function withFreshModel(): self;4647/**48* Set whether the repository should return a fresh model49* when changes are committed.50*/51public function setFreshModel(bool $fresh = true): self;5253/**54* Create a new model instance and persist it to the database.55*56* @throws \Pterodactyl\Exceptions\Model\DataValidationException57*/58public function create(array $fields, bool $validate = true, bool $force = false): mixed;5960/**61* Find a model that has the specific ID passed.62*63* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException64*/65public function find(int $id): mixed;6667/**68* Find a model matching an array of where clauses.69*/70public function findWhere(array $fields): Collection;7172/**73* Find and return the first matching instance for the given fields.74*75* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException76*/77public function findFirstWhere(array $fields): mixed;7879/**80* Return a count of records matching the passed arguments.81*/82public function findCountWhere(array $fields): int;8384/**85* Delete a given record from the database.86*/87public function delete(int $id): int;8889/**90* Delete records matching the given attributes.91*/92public function deleteWhere(array $attributes): int;9394/**95* Update a given ID with the passed array of fields.96*97* @throws \Pterodactyl\Exceptions\Model\DataValidationException98* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException99*/100public function update(int $id, array $fields, bool $validate = true, bool $force = false): mixed;101102/**103* Perform a mass update where matching records are updated using whereIn.104* This does not perform any model data validation.105*/106public function updateWhereIn(string $column, array $values, array $fields): int;107108/**109* Update a record if it exists in the database, otherwise create it.110*111* @throws \Pterodactyl\Exceptions\Model\DataValidationException112*/113public function updateOrCreate(array $where, array $fields, bool $validate = true, bool $force = false): mixed;114115/**116* Return all records associated with the given model.117*/118public function all(): Collection;119120/**121* Return a paginated result set using a search term if set on the repository.122*/123public function paginated(int $perPage): LengthAwarePaginator;124125/**126* Insert a single or multiple records into the database at once skipping127* validation and mass assignment checking.128*/129public function insert(array $data): bool;130131/**132* Insert multiple records into the database and ignore duplicates.133*/134public function insertIgnore(array $values): bool;135136/**137* Get the amount of entries in the database.138*/139public function count(): int;140}141142143