I have this table:

Models
<?php
class Post extends Eloquent {
protected $fillable = ['title', 'content', 'shortDescription', 'pictureUrl'];
public function taxonomy()
{
return $this->belongsToMany('Taxonomy')->withPivot('post_id', 'taxonomy_id');
}
}
<?php
class Taxonomy extends Eloquent{
protected $fillable = ['name', 'type', 'url'];
}
ApiController
<?php
class ApiController extends BaseController {
/**
* Fetch All Posts
*
* @return mixed
*/
public function gatAllPosts()
{
return Post::with('taxonomy')->get();
}
}
Results
{
"id": 3,
"title": "Some title",
"content": "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting.<\/p>",
"shortDescription": "",
"pictureUrl": "",
"created_at": "2014-08-21 17:22:38",
"updated_at": "2014-08-21 17:22:38",
"taxonomy": [{
"id": 1,
"name": "News",
"type": "category",
"url": "news",
"created_at": "2014-08-21 15:54:47",
"updated_at": "2014-08-21 15:54:47",
"pivot": {
"post_id": 3,
"taxonomy_id": 1
}
}]
}
How I can select, for example from taxonomies table only name and url.
{
"id": 3,
"title": "Some title",
"content": "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting.<\/p>",
"shortDescription": "",
"pictureUrl": "",
"created_at": "2014-08-21 17:22:38",
"updated_at": "2014-08-21 17:22:38",
"taxonomy": [{
"name": "News",
"url": "news"
}]
}