Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

What does your Transportation class look like?

The issue you're having is with what transportable() returns, not with Transportation itself.

Do you have a Transportation::transportable method that returns a belongsTo relationship?

Last updated 2 years ago.
0

Aggree with JoolsMcFly. I would check what $transportation->transportable() returns. If it is a relational model, it may not be able to get the related data.

Last updated 2 years ago.
0

Looks like transportable() is supposed to return a morphed relationship. I don't think it is possible to declare the morphed model from the Transportation's side of view, because it doesn't know what kind of ride or whatever other class it is supposed to morph to yet. Sounds weird, but anyway:

Maybe try to save the Transportation from the Ride's side of view:

$transportation = new Transportation;
$transportation = $ride->transportations()->save($transportation);
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.