Removing extra pivot object in Laravel's Eloquent
laravel, laravel-4, php, pivot-table
Solution
This was answered by @Anthony Sterling under the comments. I had to add 'pivot' under the protected array in the model.
<?php
class Entity extends Eloquent {
protected $hidden = array('pivot');
protected $guarded = array();
protected $fillable = array();
public $timestamps = false;
}
Problem
I'm using Laravel 4 and have my pivot tables working and pulling data as expected, but with every relation call, I end up getting an additional `pivot` object returned. For example: ``` "entities": [ { "id": 1, "name": "NAME", "short_name": "SHORT", "description": "", "pivot": { "project_id": 1, "entity_id": 1 } } ] ``` Is there a way to remove the extra pivot object in the call? Below is the current code I have in my Project model. ``` public function entities() { return $this->belongsToMany('Entity', 'project_entity'); } ```