Skip to content

Commit

Permalink
fix: Return empty model object none related
Browse files Browse the repository at this point in the history
  • Loading branch information
kkyouhei committed Mar 10, 2018
1 parent 5a8789f commit 02fb245
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/attributes/relations/BelongsTo.ts
Expand Up @@ -52,6 +52,10 @@ export default class BelongsTo extends Relation {
* instantiating a model or creating a plain object from a model.
*/
make (value: any, _parent: Record, _key: string): Model | null {
if (value === null) {
return null
}

if (value === undefined) {
return null
}
Expand Down
4 changes: 4 additions & 0 deletions src/attributes/relations/BelongsToMany.ts
Expand Up @@ -82,6 +82,10 @@ export default class BelongsToMany extends Relation {
* instantiating a model or creating a plain object from a model.
*/
make (value: any, _parent: Record, _key: string): Model[] {
if (value === null) {
return []
}

if (value === undefined) {
return []
}
Expand Down
4 changes: 4 additions & 0 deletions src/attributes/relations/HasMany.ts
Expand Up @@ -44,6 +44,10 @@ export default class HasMany extends Relation {
* instantiating a model or creating a plain object from a model.
*/
make (value: any, _parent: Record, _key: string): Model[] {
if (value === null) {
return []
}

if (value === undefined) {
return []
}
Expand Down
4 changes: 4 additions & 0 deletions src/attributes/relations/HasManyBy.ts
Expand Up @@ -44,6 +44,10 @@ export default class HasManyBy extends Relation {
* instantiating a model or creating a plain object from a model.
*/
make (value: any, _parent: Record, _key: string): Model[] {
if (value === null) {
return []
}

if (value === undefined) {
return []
}
Expand Down
4 changes: 4 additions & 0 deletions src/attributes/relations/HasManyThrough.ts
Expand Up @@ -72,6 +72,10 @@ export default class HasManyThrough extends Relation {
* instantiating a model or creating a plain object from a model.
*/
make (value: any, _parent: Record, _key: string): Model[] {
if (value === null) {
return []
}

if (value === undefined) {
return []
}
Expand Down
4 changes: 4 additions & 0 deletions src/attributes/relations/HasOne.ts
Expand Up @@ -52,6 +52,10 @@ export default class HasOne extends Relation {
* instantiating a model or creating a plain object from a model.
*/
make (value: any, _parent: Record, _key: string): Model | null {
if (value === null) {
return null
}

if (value === undefined) {
return null
}
Expand Down
4 changes: 4 additions & 0 deletions src/attributes/relations/MorphMany.ts
Expand Up @@ -52,6 +52,10 @@ export default class MorphMany extends Relation {
* instantiating a model or creating a plain object from a model.
*/
make (value: any, _parent: Record, _key: string): Model[] {
if (value === null) {
return []
}

if (value === undefined) {
return []
}
Expand Down
4 changes: 4 additions & 0 deletions src/attributes/relations/MorphOne.ts
Expand Up @@ -60,6 +60,10 @@ export default class MorphOne extends Relation {
* instantiating a model or creating a plain object from a model.
*/
make (value: any, _parent: Record, _key: string): Model | null {
if (value === null) {
return null
}

if (value === undefined) {
return null
}
Expand Down
4 changes: 4 additions & 0 deletions src/attributes/relations/MorphTo.ts
Expand Up @@ -48,6 +48,10 @@ export default class MorphTo extends Relation {
* instantiating a model or creating a plain object from a model.
*/
make (value: any, parent: Record, _key: string): Model | null {
if (value === null) {
return null
}

if (value === undefined) {
return null
}
Expand Down
4 changes: 4 additions & 0 deletions src/attributes/relations/MorphToMany.ts
Expand Up @@ -80,6 +80,10 @@ export default class MorphToMany extends Relation {
* instantiating a model or creating a plain object from a model.
*/
make (value: any, _parent: Record, _key: string): Model[] {
if (value === null) {
return []
}

if (value === undefined) {
return []
}
Expand Down
4 changes: 4 additions & 0 deletions src/attributes/relations/MorphedByMany.ts
Expand Up @@ -80,6 +80,10 @@ export default class MorphedByMany extends Relation {
* instantiating a model or creating a plain object from a model.
*/
make (value: any, _parent: Record, _key: string): Model[] {
if (value === null) {
return []
}

if (value === undefined) {
return []
}
Expand Down

0 comments on commit 02fb245

Please sign in to comment.