I'm using a more complex solution with trait, but I'll try to simplify it now.
I have such a polymorphic relation:
class Attraction extends Model
{
/**
* Get the coordinate of this object.
*/
public function coordinate()
{
return $this->morphMany(Coordinate::class, 'object');
}
}
class Coordinate extends Model
{
/**
* Get the object of this coordinate.
*
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
*/
public function object()
{
return $this->morphTo();
}
}
and in controller I'm trying to update it in such a way
$attraction->coordinate()->update($request->all());
and receive such an error
SQLSTATE[42S22]: Column not found: 1054 Unknown column '_method' in 'field list'...
basically, it's ignoring $fillable
and is trying to update from all the data I've passed via $request->all()
.
Do I miss something? If not, I'll update my example to a not simplified version, but...it's basically a "Geocodable" trait in Attraction
model, nothing, that should change the behavior of update()
.