55use Illuminate \Contracts \Pagination \LengthAwarePaginator ;
66use Illuminate \Database \Eloquent \Model ;
77use Illuminate \Support \Collection ;
8+ use InvalidArgumentException ;
89use Saritasa \DingoApi \Paging \CursorRequest ;
910use Saritasa \DingoApi \Paging \CursorResult ;
1011use Saritasa \DingoApi \Paging \PagingInfo ;
1112use Saritasa \LaravelRepositories \DTO \SortOptions ;
13+ use Saritasa \LaravelRepositories \Exceptions \BadCriteriaException ;
1214use Saritasa \LaravelRepositories \Exceptions \ModelNotFoundException ;
1315use Saritasa \LaravelRepositories \Exceptions \RepositoryException ;
1416
@@ -39,21 +41,26 @@ public function getModelValidationRules(): array;
3941 * @return Model
4042 *
4143 * @throws ModelNotFoundException
44+ * @throws RepositoryException
4245 */
4346 public function findOrFail ($ id ): Model ;
4447
4548 /**
4649 * Returns first model matching given filters.
4750 *
4851 * @param array $fieldValues Filters collection
52+ *
4953 * @return Model|null
54+ *
55+ * @throws BadCriteriaException
5056 */
5157 public function findWhere (array $ fieldValues ): ?Model ;
5258
5359 /**
5460 * Create model in storage.
5561 *
5662 * @param Model $entity Model to create
63+ *
5764 * @return Model
5865 *
5966 * @throws RepositoryException
@@ -75,6 +82,7 @@ public function save(Model $entity): Model;
7582 * Delete model in storage.
7683 *
7784 * @param Model $entity Model to delete
85+ *
7886 * @return void
7987 *
8088 * @throws RepositoryException
@@ -84,7 +92,7 @@ public function delete(Model $entity): void;
8492 /**
8593 * Returns models list.
8694 *
87- * @return Collection
95+ * @return Collection|Model[]
8896 */
8997 public function get (): Collection ;
9098
@@ -93,27 +101,34 @@ public function get(): Collection;
93101 *
94102 * @param array $fieldValues Filters collection
95103 *
96- * @return Collection
104+ * @return Collection|Model[]
105+ *
106+ * @throws BadCriteriaException
97107 */
98108 public function getWhere (array $ fieldValues ): Collection ;
99109
100110 /**
101111 * Get models collection as pagination.
102112 *
103113 * @param PagingInfo $paging Paging information
104- * @param array|null $fieldValues Filters collection
114+ * @param array $fieldValues Filters collection
105115 *
106116 * @return LengthAwarePaginator
117+ *
118+ * @throws BadCriteriaException
119+ * @throws InvalidArgumentException
107120 */
108121 public function getPage (PagingInfo $ paging , array $ fieldValues = []): LengthAwarePaginator ;
109122
110123 /**
111124 * Get models collection as cursor.
112125 *
113126 * @param CursorRequest $cursor Request with cursor data
114- * @param array|null $fieldValues Filters collection
127+ * @param array $fieldValues Filters collection
115128 *
116129 * @return CursorResult
130+ *
131+ * @throws BadCriteriaException
117132 */
118133 public function getCursorPage (CursorRequest $ cursor , array $ fieldValues = []): CursorResult ;
119134
@@ -123,29 +138,35 @@ public function getCursorPage(CursorRequest $cursor, array $fieldValues = []): C
123138 * @param array $with Which relations should be preloaded
124139 * @param array $withCounts Which related entities should be counted
125140 * @param array $fieldValues Conditions that retrieved entities should satisfy
126- * @param SortOptions $sortOptions How list of items should be sorted
141+ * @param SortOptions|null $sortOptions How list of items should be sorted
127142 *
128- * @return Collection
143+ * @return Collection|Model[]
144+ *
145+ * @throws BadCriteriaException
129146 */
130147 public function getWith (
131148 array $ with ,
132149 array $ withCounts = [],
133150 array $ fieldValues = [],
134- SortOptions $ sortOptions = null
151+ ? SortOptions $ sortOptions = null
135152 ): Collection ;
136153
137154 /**
138155 * Return entities count.
139156 *
157+ * @param array $fieldValues Conditions that retrieved entities should satisfy
158+ *
140159 * @return integer
160+ *
161+ * @throws BadCriteriaException
141162 */
142- public function count (): int ;
163+ public function count (array $ fieldValues = [] ): int ;
143164
144165 /**
145166 * List of fields, allowed to use in the search.
146167 * Should be determine in the inheritors. Determines the result of the list request of entities.
147168 *
148- * @return array
169+ * @return array
149170 */
150171 public function getSearchableFields (): array ;
151172}
0 commit comments