Skip to content

Commit ef83fdb

Browse files
committed
Style updates
1 parent 8b69116 commit ef83fdb

6 files changed

Lines changed: 26 additions & 29 deletions

File tree

README.md

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,7 @@ You can also update, re-arrange (for one-to-many relationships), and delete rela
7070
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`.
7171

7272
```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-
}
73+
HasMany::make('Images', 'images', Image::class)->inline()->sortUsing('weight'),
8974
```
9075

9176

dist/js/field.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/components/FormField.vue

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<draggable
1010
v-model="items"
1111
handle=".relationship-item-handle"
12-
:disabled="!field.sortable"
12+
:disabled="! field.sortable"
1313
@start="drag=true"
1414
@end="drag=false"
1515
>
@@ -91,15 +91,23 @@ export default {
9191
setInitialValue() {
9292
this.items = Array.isArray(this.field.value) ? this.field.value : [];
9393
this.items = this.items.map((item, index) => {
94-
return { 'id': this.getNextId(), 'modelId': this.field.models[index], 'fields':item }
94+
return {
95+
'id': this.getNextId(),
96+
'modelId': this.field.models[index],
97+
'fields': item
98+
}
9599
});
96100
97101
if(this.field.singular){
98102
this.items.splice(1);
99103
}
100104
101105
if(this.field.addChildAtStart && (this.items.length === 0)){
102-
this.items.push({ 'id': this.getNextId(), 'modelId': 0, 'fields': {...this.field.settings}});
106+
this.items.push({
107+
'id': this.getNextId(),
108+
'modelId': 0,
109+
'fields': {...this.field.settings}
110+
});
103111
}
104112
},
105113
@@ -146,7 +154,11 @@ export default {
146154
147155
addItem(){
148156
let value = [...this.items];
149-
value.push({ 'id': this.getNextId(), 'modelId': 0, 'fields': {...this.field.settings}});
157+
value.push({
158+
'id': this.getNextId(),
159+
'modelId': 0,
160+
'fields': {...this.field.settings}
161+
});
150162
this.handleChange(value);
151163
},
152164
}

resources/js/components/RelationshipFormItem.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,20 @@
117117
},
118118
119119
fill(formData, parentAttrib) {
120-
formData.append(`${parentAttrib}[${this.id}][modelId]`, this.modelId);
120+
formData.append(`${parentAttrib}[${this.id}][modelId]`, this.modelId);
121121
this.getValueFromChildren().forEach(
122122
(value, key) => {
123123
let keyParts = key.split('_');
124124
125125
if (keyParts.length === 1) {
126126
formData.append(`${parentAttrib}[${this.id}][values][${key}]`, value);
127-
} else {
128-
let parentParts = parentAttrib.split('_');
129-
let attrib = keyParts.slice(parentParts.length + 1).join('_');
130-
131-
formData.append(`${parentAttrib}[${this.id}][values][${attrib}]`, value);
127+
return;
132128
}
129+
130+
let parentParts = parentAttrib.split('_');
131+
let attrib = keyParts.slice(parentParts.length + 1).join('_');
132+
133+
formData.append(`${parentAttrib}[${this.id}][values][${attrib}]`, value);
133134
}
134135
);
135136
},

src/Observers/HasManyObserver.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function updating(Model $model, $attribute, $value)
2626

2727
continue;
2828
}
29+
2930
$childModel->update($value[$i]['fields']);
3031
}
3132
}

tests/Unit/HasOneTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ public function testFillAttributeForDelete()
117117
$newEmployee = Employee::create(['name' => 'Test']);
118118
$newEmployee->profile()->save(Profile::make(['phone' => '123123123']));
119119

120-
$id = $newEmployee->fresh()->profile->id;
121-
122120
$updateRequest = [
123121
'name' => 'Test 2',
124122
'profile' => [

0 commit comments

Comments
 (0)