How can i tell laravel to return the relationship results in same name as the relationship function?
ex. I have relationship called mediaItem
and when i call $model->with('mediaItem') is is returned as {media_item: {}}
. Is there a way that it is returned as {mediaItem:{}}?
No, sorry.
@GrahamCampbell Isn't public static $snakeAttributes = false;
attribute the solution to this?
ref: https://github.com/laravel/framework/blob/5.2/src/Illuminate/Database/Eloquent/Model.php#L204
@klimentLambevski you can solve this using:
Network.php
public function pointsOfSale()
{
return $this->hasMany(PointOfSale::class);
}
PointOfSale.php
public function network()
{
return $this->belongsTo(Network::class, 'networkId');
}
Most helpful comment
@GrahamCampbell Isn't
public static $snakeAttributes = false;
attribute the solution to this?ref: https://github.com/laravel/framework/blob/5.2/src/Illuminate/Database/Eloquent/Model.php#L204