Skip to content

Commit a24cb69

Browse files
committed
Update readme
1 parent 44b1f81 commit a24cb69

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,28 @@ You can also update, re-arrange (for one-to-many relationships), and delete rela
6767

6868
![Rearrange Models](https://raw.githubusercontent.com/kirschbaum-development/nova-inline-relationship/master/screenshots/UpdateView.png "Rearrange Models")
6969

70+
To rearrange a model you should specify an `integer` field which will be used to sort models. For example, in the following code we will use a field named `weight` to store the sorting order for `Images`.
71+
72+
```php
73+
namespace App\Nova;
74+
75+
use Laravel\Nova\Fields\Image;
76+
77+
class BlogPost extends Resource
78+
{
79+
//...
80+
public function fields(Request $request)
81+
{
82+
return [
83+
//...
84+
85+
HasMany::make('Images', 'images', Image::class)->inline()->sortUsing('weight'),
86+
];
87+
}
88+
}
89+
```
90+
91+
7092
## Required Relationships
7193

7294
Occasionally you may want to require a child relationship during the creation of a model. To do this, just use the `requireChild()` method. As an example, you may want to create a new user and enforce that a new profile for the user is also created.

0 commit comments

Comments
 (0)