2015-12-06 18:58:49 +00:00
|
|
|
<?php
|
2017-09-26 02:43:01 +00:00
|
|
|
/**
|
2016-01-20 21:05:16 +00:00
|
|
|
* Pterodactyl - Panel
|
2017-01-24 22:57:08 +00:00
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
2016-01-20 00:10:39 +00:00
|
|
|
*
|
2017-09-26 02:43:01 +00:00
|
|
|
* This software is licensed under the terms of the MIT license.
|
|
|
|
* https://opensource.org/licenses/MIT
|
2016-01-20 00:10:39 +00:00
|
|
|
*/
|
2015-12-06 18:58:49 +00:00
|
|
|
|
2017-07-01 20:29:49 +00:00
|
|
|
namespace Pterodactyl\Contracts\Repository;
|
2015-12-06 18:58:49 +00:00
|
|
|
|
2017-07-01 20:29:49 +00:00
|
|
|
interface RepositoryInterface
|
2016-12-07 22:46:38 +00:00
|
|
|
{
|
2017-07-08 19:07:51 +00:00
|
|
|
/**
|
|
|
|
* Return an identifier or Model object to be used by the repository.
|
|
|
|
*
|
|
|
|
* @return string|\Closure|object
|
|
|
|
*/
|
2017-07-01 20:29:49 +00:00
|
|
|
public function model();
|
|
|
|
|
2017-07-08 19:07:51 +00:00
|
|
|
/**
|
|
|
|
* Return the model being used for this repository instance.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2017-07-01 20:29:49 +00:00
|
|
|
public function getModel();
|
|
|
|
|
2017-07-08 19:07:51 +00:00
|
|
|
/**
|
|
|
|
* Returns an instance of a query builder.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2017-07-01 20:29:49 +00:00
|
|
|
public function getBuilder();
|
|
|
|
|
2017-07-08 19:07:51 +00:00
|
|
|
/**
|
|
|
|
* Returns the colummns to be selected or returned by the query.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2017-07-01 20:29:49 +00:00
|
|
|
public function getColumns();
|
|
|
|
|
2017-07-08 19:07:51 +00:00
|
|
|
/**
|
|
|
|
* An array of columns to filter the response by.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param array $columns
|
2017-07-08 19:07:51 +00:00
|
|
|
* @return $this
|
|
|
|
*/
|
2017-07-01 20:29:49 +00:00
|
|
|
public function withColumns($columns = ['*']);
|
|
|
|
|
2017-07-08 19:07:51 +00:00
|
|
|
/**
|
|
|
|
* Disable returning a fresh model when data is inserted or updated.
|
|
|
|
*
|
|
|
|
* @return $this
|
|
|
|
*/
|
|
|
|
public function withoutFresh();
|
2017-07-01 20:29:49 +00:00
|
|
|
|
2017-07-08 19:07:51 +00:00
|
|
|
/**
|
|
|
|
* Create a new model instance and persist it to the database.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param array $fields
|
|
|
|
* @param bool $validate
|
2017-08-31 02:11:14 +00:00
|
|
|
* @param bool $force
|
2017-07-08 19:07:51 +00:00
|
|
|
* @return mixed
|
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
|
|
*/
|
2017-08-31 02:11:14 +00:00
|
|
|
public function create(array $fields, $validate = true, $force = false);
|
2017-07-08 19:07:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete a given record from the database.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param int $id
|
2017-08-09 02:21:10 +00:00
|
|
|
* @return int
|
2017-07-08 19:07:51 +00:00
|
|
|
*/
|
2017-07-01 20:29:49 +00:00
|
|
|
public function delete($id);
|
|
|
|
|
2017-08-09 02:21:10 +00:00
|
|
|
/**
|
|
|
|
* Delete records matching the given attributes.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param array $attributes
|
2017-08-09 02:21:10 +00:00
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function deleteWhere(array $attributes);
|
|
|
|
|
2017-07-08 19:07:51 +00:00
|
|
|
/**
|
|
|
|
* Find a model that has the specific ID passed.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param int $id
|
2017-07-08 19:07:51 +00:00
|
|
|
* @return mixed
|
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
|
|
*/
|
2017-07-01 20:29:49 +00:00
|
|
|
public function find($id);
|
|
|
|
|
2017-07-08 19:07:51 +00:00
|
|
|
/**
|
|
|
|
* Find a model matching an array of where clauses.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param array $fields
|
2017-07-08 19:07:51 +00:00
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function findWhere(array $fields);
|
2017-07-01 20:29:49 +00:00
|
|
|
|
2017-07-08 20:04:59 +00:00
|
|
|
/**
|
|
|
|
* Find and return the first matching instance for the given fields.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param array $fields
|
2017-07-08 20:04:59 +00:00
|
|
|
* @return mixed
|
2017-09-16 03:13:33 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2017-07-08 20:04:59 +00:00
|
|
|
*/
|
|
|
|
public function findFirstWhere(array $fields);
|
|
|
|
|
2017-08-05 22:20:07 +00:00
|
|
|
/**
|
|
|
|
* Return a count of records matching the passed arguments.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param array $fields
|
2017-08-05 22:20:07 +00:00
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function findCountWhere(array $fields);
|
|
|
|
|
2017-07-08 19:07:51 +00:00
|
|
|
/**
|
|
|
|
* Update a given ID with the passed array of fields.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param int $id
|
|
|
|
* @param array $fields
|
|
|
|
* @param bool $validate
|
|
|
|
* @param bool $force
|
2017-07-08 19:07:51 +00:00
|
|
|
* @return mixed
|
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
|
|
*/
|
|
|
|
public function update($id, array $fields, $validate = true, $force = false);
|
2017-07-01 20:29:49 +00:00
|
|
|
|
2017-07-24 00:57:43 +00:00
|
|
|
/**
|
|
|
|
* Perform a mass update where matching records are updated using whereIn.
|
|
|
|
* This does not perform any model data validation.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param string $column
|
|
|
|
* @param array $values
|
|
|
|
* @param array $fields
|
2017-07-24 00:57:43 +00:00
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function updateWhereIn($column, array $values, array $fields);
|
|
|
|
|
2017-07-25 02:34:10 +00:00
|
|
|
/**
|
|
|
|
* Update a record if it exists in the database, otherwise create it.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param array $where
|
|
|
|
* @param array $fields
|
|
|
|
* @param bool $validate
|
|
|
|
* @param bool $force
|
2017-07-25 02:34:10 +00:00
|
|
|
* @return mixed
|
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
|
|
*/
|
|
|
|
public function updateOrCreate(array $where, array $fields, $validate = true, $force = false);
|
|
|
|
|
2017-07-08 19:07:51 +00:00
|
|
|
/**
|
|
|
|
* Update multiple records matching the passed clauses.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param array $where
|
|
|
|
* @param array $fields
|
2017-07-08 19:07:51 +00:00
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function massUpdate(array $where, array $fields);
|
2017-07-15 16:52:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return all records from the model.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function all();
|
2017-07-20 01:49:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Insert a single or multiple records into the database at once skipping
|
|
|
|
* validation and mass assignment checking.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param array $data
|
2017-07-20 01:49:41 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function insert(array $data);
|
2017-08-06 02:10:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Insert multiple records into the database and ignore duplicates.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param array $values
|
2017-08-06 02:10:32 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function insertIgnore(array $values);
|
2015-12-06 18:58:49 +00:00
|
|
|
}
|