Skip to content

Commit afc2e93

Browse files
committed
PHPORM-216 Remove $collection setting from DocumentModel and Connection::collection(). Use $table and Connection::table() instead
1 parent 73c18e9 commit afc2e93

File tree

3 files changed

+4
-52
lines changed

3 files changed

+4
-52
lines changed

src/Connection.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
use function is_array;
2323
use function preg_match;
2424
use function str_contains;
25-
use function trigger_error;
2625

27-
use const E_USER_DEPRECATED;
2826
use const FILTER_FLAG_IPV6;
2927
use const FILTER_VALIDATE_IP;
3028

@@ -77,22 +75,6 @@ public function __construct(array $config)
7775
$this->useDefaultQueryGrammar();
7876
}
7977

80-
/**
81-
* Begin a fluent query against a database collection.
82-
*
83-
* @deprecated since mongodb/laravel-mongodb 4.8, use the function table() instead
84-
*
85-
* @param string $collection
86-
*
87-
* @return Query\Builder
88-
*/
89-
public function collection($collection)
90-
{
91-
@trigger_error('Since mongodb/laravel-mongodb 4.8, the method Connection::collection() is deprecated and will be removed in version 5.0. Use the table() method instead.', E_USER_DEPRECATED);
92-
93-
return $this->table($collection);
94-
}
95-
9678
/**
9779
* Begin a fluent query against a database collection.
9880
*

src/Eloquent/DocumentModel.php

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,8 @@
4646
use function str_contains;
4747
use function str_starts_with;
4848
use function strcmp;
49-
use function trigger_error;
5049
use function var_export;
5150

52-
use const E_USER_DEPRECATED;
53-
5451
trait DocumentModel
5552
{
5653
use HybridRelations;
@@ -141,18 +138,6 @@ public function freshTimestamp()
141138
return new UTCDateTime(Date::now());
142139
}
143140

144-
/** @inheritdoc */
145-
public function getTable()
146-
{
147-
if (isset($this->collection)) {
148-
trigger_error('Since mongodb/laravel-mongodb 4.8: Using "$collection" property is deprecated. Use "$table" instead.', E_USER_DEPRECATED);
149-
150-
return $this->collection;
151-
}
152-
153-
return parent::getTable();
154-
}
155-
156141
/** @inheritdoc */
157142
public function getAttribute($key)
158143
{
@@ -735,6 +720,10 @@ public function save(array $options = [])
735720
unset($this->attributes['_id']);
736721
}
737722

723+
if (array_key_exists('id', $this->attributes) && $this->attributes['id'] === null) {
724+
unset($this->attributes['id']);
725+
}
726+
738727
$saved = parent::save($options);
739728

740729
// Clear list of unset fields

src/Schema/Builder.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@
1717
use function iterator_to_array;
1818
use function sort;
1919
use function sprintf;
20-
use function trigger_error;
2120
use function usort;
2221

23-
use const E_USER_DEPRECATED;
24-
2522
class Builder extends \Illuminate\Database\Schema\Builder
2623
{
2724
/**
@@ -75,22 +72,6 @@ public function hasTable($table)
7572
return $this->hasCollection($table);
7673
}
7774

78-
/**
79-
* Modify a collection on the schema.
80-
*
81-
* @deprecated since mongodb/laravel-mongodb 4.8, use the function table() instead
82-
*
83-
* @param string $collection
84-
*
85-
* @return void
86-
*/
87-
public function collection($collection, Closure $callback)
88-
{
89-
@trigger_error('Since mongodb/laravel-mongodb 4.8, the method Schema\Builder::collection() is deprecated and will be removed in version 5.0. Use the function table() instead.', E_USER_DEPRECATED);
90-
91-
$this->table($collection, $callback);
92-
}
93-
9475
/** @inheritdoc */
9576
public function table($table, Closure $callback)
9677
{

0 commit comments

Comments
 (0)