|
| 1 | +<?php |
| 2 | +/* |
| 3 | + * Pterodactyl - Panel |
| 4 | + * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | + * of this software and associated documentation files (the "Software"), to deal |
| 8 | + * in the Software without restriction, including without limitation the rights |
| 9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | + * copies of the Software, and to permit persons to whom the Software is |
| 11 | + * furnished to do so, subject to the following conditions: |
| 12 | + * |
| 13 | + * The above copyright notice and this permission notice shall be included in all |
| 14 | + * copies or substantial portions of the Software. |
| 15 | + * |
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | + * SOFTWARE. |
| 23 | + */ |
| 24 | + |
| 25 | +namespace Pterodactyl\Contracts\Repositories; |
| 26 | + |
| 27 | +use Illuminate\Container\Container; |
| 28 | + |
| 29 | +interface RepositoryInterface |
| 30 | +{ |
| 31 | + /** |
| 32 | + * RepositoryInterface constructor. |
| 33 | + * |
| 34 | + * @param \Illuminate\Container\Container $container |
| 35 | + */ |
| 36 | + public function __construct(Container $container); |
| 37 | + |
| 38 | + /** |
| 39 | + * Define the model class to be loaded. |
| 40 | + * |
| 41 | + * @return string |
| 42 | + */ |
| 43 | + public function model(); |
| 44 | + |
| 45 | + /** |
| 46 | + * Returns the raw model class. |
| 47 | + * |
| 48 | + * @return \Illuminate\Database\Eloquent\Model |
| 49 | + */ |
| 50 | + public function getModel(); |
| 51 | + |
| 52 | + /** |
| 53 | + * Make the model instance. |
| 54 | + * |
| 55 | + * @return \Illuminate\Database\Eloquent\Model |
| 56 | + * @throws \Pterodactyl\Exceptions\Repository\RepositoryException |
| 57 | + */ |
| 58 | + public function makeModel(); |
| 59 | + |
| 60 | + /** |
| 61 | + * Return all of the currently defined rules. |
| 62 | + * |
| 63 | + * @return array |
| 64 | + */ |
| 65 | + public function getRules(); |
| 66 | + |
| 67 | + /** |
| 68 | + * Return the rules to apply when updating a model. |
| 69 | + * |
| 70 | + * @return array |
| 71 | + */ |
| 72 | + public function getUpdateRules(); |
| 73 | + |
| 74 | + /** |
| 75 | + * Return the rules to apply when creating a model. |
| 76 | + * |
| 77 | + * @return array |
| 78 | + */ |
| 79 | + public function getCreateRules(); |
| 80 | + |
| 81 | + /** |
| 82 | + * Add relations to a model for retrieval. |
| 83 | + * |
| 84 | + * @param array $params |
| 85 | + * @return $this |
| 86 | + */ |
| 87 | + public function with(...$params); |
| 88 | + |
| 89 | + /** |
| 90 | + * Add count of related items to model when retrieving. |
| 91 | + * |
| 92 | + * @param array $params |
| 93 | + * @return $this |
| 94 | + */ |
| 95 | + public function withCount(...$params); |
| 96 | + |
| 97 | + /** |
| 98 | + * Get all records from the database. |
| 99 | + * |
| 100 | + * @param array $columns |
| 101 | + * @return mixed |
| 102 | + */ |
| 103 | + public function all(array $columns = ['*']); |
| 104 | + |
| 105 | + /** |
| 106 | + * Return a paginated result set. |
| 107 | + * |
| 108 | + * @param int $limit |
| 109 | + * @param array $columns |
| 110 | + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator |
| 111 | + */ |
| 112 | + public function paginate($limit = 15, array $columns = ['*']); |
| 113 | + |
| 114 | + /** |
| 115 | + * Create a new record on the model. |
| 116 | + * |
| 117 | + * @param array $data |
| 118 | + * @return \Illuminate\Database\Eloquent\Model |
| 119 | + */ |
| 120 | + public function create(array $data); |
| 121 | + |
| 122 | + /** |
| 123 | + * Update the model. |
| 124 | + * |
| 125 | + * @param $attributes |
| 126 | + * @param array $data |
| 127 | + * @return int |
| 128 | + */ |
| 129 | + public function update($attributes, array $data); |
| 130 | + |
| 131 | + /** |
| 132 | + * Delete a model from the database. Handles soft deletion. |
| 133 | + * |
| 134 | + * @param int $id |
| 135 | + * @return mixed |
| 136 | + */ |
| 137 | + public function delete($id); |
| 138 | + |
| 139 | + /** |
| 140 | + * Destroy the model from the database. Ignores soft deletion. |
| 141 | + * |
| 142 | + * @param int $id |
| 143 | + * @return mixed |
| 144 | + */ |
| 145 | + public function destroy($id); |
| 146 | + |
| 147 | + /** |
| 148 | + * Find a given model by ID or IDs. |
| 149 | + * |
| 150 | + * @param int|array $id |
| 151 | + * @param array $columns |
| 152 | + * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection |
| 153 | + */ |
| 154 | + public function find($id, array $columns = ['*']); |
| 155 | + |
| 156 | + /** |
| 157 | + * Finds the first record matching a passed array of values. |
| 158 | + * |
| 159 | + * @param array $attributes |
| 160 | + * @param array $columns |
| 161 | + * @return \Illuminate\Database\Eloquent\Model |
| 162 | + */ |
| 163 | + public function findBy(array $attributes, array $columns = ['*']); |
| 164 | +} |
0 commit comments