You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/upgrade.md
+19-43Lines changed: 19 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,32 +1,10 @@
1
1
# 1.x -> 2.x
2
-
2.x has a number of breaking API changes.
2
+
2.x has a number of breaking API changes to be aware of. First, be aware that the minimum required PHP version is now 8.1. Other than that, there are some key API changes to be aware of.
Much of the old `find` functionality has been moved to `Relation`. Most notably, the `conditions` argument is no longer supported, and has been replaced by `where()`:
31
9
```php
32
10
// 1.x
@@ -68,7 +46,7 @@ $book = Book::first();
68
46
$book = Book::last();
69
47
```
70
48
71
-
## `Model::all`
49
+
###`Model::all`
72
50
`Model::all()` no longer takes any arguments, and now returns an iterable `Relation` instead of an array of models:
The static `table` accessor on `Model` is now protected. If you were making calls directly on `Table`, you will need to refactor your code.
139
117
```php
140
118
// 1.x
@@ -150,11 +128,11 @@ If you do need access to the table instance for some reason, you can still get t
150
128
```
151
129
152
130
153
-
#static properties
131
+
## Static Properties
154
132
155
133
The static relationship properties have changed shape, moving from a flat array to a key-config format:
156
134
157
-
## `Model::$has_one`
135
+
###`Model::$has_one`
158
136
159
137
```php
160
138
// 1.x
@@ -183,7 +161,7 @@ class Author extends ActiveRecord
183
161
}
184
162
```
185
163
186
-
## `Model::$has_many`
164
+
###`Model::$has_many`
187
165
188
166
```php
189
167
// 1.x
@@ -209,7 +187,7 @@ class Person extends ActiveRecord
209
187
}
210
188
```
211
189
212
-
## `Model::$belongs_to`
190
+
###`Model::$belongs_to`
213
191
214
192
```php
215
193
// 1.x
@@ -234,7 +212,7 @@ class Person extends ActiveRecord
234
212
}
235
213
```
236
214
237
-
## `Model::$validates_inclusion_of`
215
+
###`Model::$validates_inclusion_of`
238
216
239
217
(note: the same changes apply for `Model::$validates_exclusion_of`)
240
218
@@ -257,9 +235,9 @@ class Book extends ActiveRecord
257
235
}
258
236
```
259
237
260
-
#other changes
238
+
## Other Changes
261
239
262
-
## `Table::update`
240
+
###`Table::update`
263
241
You generally shouldn't be working directly with a `Table` instance, but if you are you should be aware that the `update` method has changed shape:
264
242
```php
265
243
// 1.x
@@ -274,7 +252,7 @@ $options = [
274
252
$table->update([ 'title' => 'Walden' ], $options); // where $options is a RelationOptions.
275
253
```
276
254
277
-
## `Table::delete`
255
+
###`Table::delete`
278
256
You generally shouldn't be working directly with a `Table` instance, but if you are you should be aware that the `delete` method has changed shape:
279
257
```php
280
258
// 1.x
@@ -289,7 +267,7 @@ $options = [
289
267
$table->delete($options); // where $options is a RelationOptions.
290
268
```
291
269
292
-
## `Config::set_model_directory`
270
+
###`Config::set_model_directory`
293
271
294
272
`Config::set_model_directory` has been removed, meaning that the active record library no longer maintains its own autoloader or knowledge of where your models are kept. In 2.0 it is recommended to use your own autoloader to manage your models as you would any other classes in your project.
295
273
@@ -321,9 +299,7 @@ class Author extends Model
321
299
322
300
```
323
301
324
-
# other changes
325
-
326
-
## exceptions location
302
+
### exceptions location
327
303
328
304
All crafted exceptions have moved to a new home in the `Exceptions` namespace.
0 commit comments