File tree Expand file tree Collapse file tree 3 files changed +37
-10
lines changed Expand file tree Collapse file tree 3 files changed +37
-10
lines changed Original file line number Diff line number Diff line change 99use Illuminate \Pagination \LengthAwarePaginator ;
1010use Illuminate \Pagination \Paginator ;
1111use MongoDB \BSON \ObjectID ;
12+ use MongoDB \Driver \Exception \LogicException ;
13+ use MongoDB \Laravel \Eloquent \Model as MongoDBModel ;
1214
1315use function array_key_exists ;
1416use function array_values ;
@@ -195,10 +197,15 @@ public function destroy($ids = [])
195197 /**
196198 * Delete all embedded models.
197199 *
198- * @return int
200+ * @param null $id
201+ *
202+ * @throws LogicException|\Throwable
203+ *
204+ * @note The $id is not used to delete embedded models.
199205 */
200- public function delete ()
206+ public function delete ($ id = null ): int
201207 {
208+ throw_if ($ id !== null , new LogicException ('The id parameter should not be used. ' ));
202209 // Overwrite the local key with an empty array.
203210 $ result = $ this ->query ->update ([$ this ->localKey => []]);
204211
@@ -224,9 +231,9 @@ public function detach($ids = [])
224231 /**
225232 * Save alias.
226233 *
227- * @return Model
234+ * @return MongoDBModel
228235 */
229- public function attach (Model $ model )
236+ public function attach (MongoDBModel $ model )
230237 {
231238 return $ this ->save ($ model );
232239 }
Original file line number Diff line number Diff line change 66
77use Illuminate \Database \Eloquent \Model ;
88use MongoDB \BSON \ObjectID ;
9+ use MongoDB \Driver \Exception \LogicException ;
10+ use Throwable ;
11+
12+ use function throw_if ;
913
1014class EmbedsOne extends EmbedsOneOrMany
1115{
@@ -133,10 +137,16 @@ public function dissociate()
133137 /**
134138 * Delete all embedded models.
135139 *
136- * @return int
140+ * @param ?string $id
141+ *
142+ * @throws LogicException|Throwable
143+ *
144+ * @note The $id is not used to delete embedded models.
137145 */
138- public function delete ()
146+ public function delete ($ id = null ): int
139147 {
148+ throw_if ($ id !== null , new LogicException ('The id parameter should not be used. ' ));
149+
140150 return $ this ->performDelete ();
141151 }
142152
Original file line number Diff line number Diff line change 88use Illuminate \Database \Eloquent \Collection ;
99use Illuminate \Database \Eloquent \Model as EloquentModel ;
1010use Illuminate \Database \Eloquent \Relations \Relation ;
11+ use Illuminate \Database \Query \Expression ;
12+ use MongoDB \Driver \Exception \LogicException ;
1113use MongoDB \Laravel \Eloquent \Model ;
14+ use Throwable ;
1215
1316use function array_merge ;
1417use function count ;
1518use function is_array ;
19+ use function throw_if ;
1620
1721abstract class EmbedsOneOrMany extends Relation
1822{
@@ -99,10 +103,16 @@ public function get($columns = ['*'])
99103 /**
100104 * Get the number of embedded models.
101105 *
102- * @return int
106+ * @param Expression|string $columns
107+ *
108+ * @throws LogicException|Throwable
109+ *
110+ * @note The $column parameter is not used to count embedded models.
103111 */
104- public function count ()
112+ public function count ($ columns = ' * ' ): int
105113 {
114+ throw_if ($ columns !== '* ' , new LogicException ('The columns parameter should not be used. ' ));
115+
106116 return count ($ this ->getEmbedded ());
107117 }
108118
@@ -392,8 +402,8 @@ public function getQualifiedForeignKeyName()
392402 /**
393403 * Get the name of the "where in" method for eager loading.
394404 *
395- * @param \Illuminate\Database\Eloquent\Model $model
396- * @param string $key
405+ * @param EloquentModel $model
406+ * @param string $key
397407 *
398408 * @return string
399409 */
You can’t perform that action at this time.
0 commit comments