Json 如何获取具有一个的对象

Json 如何获取具有一个的对象,json,laravel-5,blade,has-one,Json,Laravel 5,Blade,Has One,我有一个模型请求,其中包含类别的外键和买家集合 class Request extends Model { // TABLE NAME protected $table = 'requests'; // MASS ASSIGMENTS protected $guarded = ['id']; // FK public function category() { return $this->hasOne('App\Objects\Category', 'id'); } //

我有一个模型请求,其中包含类别的外键和买家集合

class Request extends Model {

// TABLE NAME
protected $table = 'requests';

// MASS ASSIGMENTS
protected $guarded = ['id'];

// FK
public function category()
{
    return $this->hasOne('App\Objects\Category', 'id');
}

// FK
public function buyers()
{
    return $this->hasMany('App\Objects\RequestBuyer');
}


}
$requests = Request::with('buyers')->get();
我有一个查询,可以获取买家集合的所有请求记录

class Request extends Model {

// TABLE NAME
protected $table = 'requests';

// MASS ASSIGMENTS
protected $guarded = ['id'];

// FK
public function category()
{
    return $this->hasOne('App\Objects\Category', 'id');
}

// FK
public function buyers()
{
    return $this->hasMany('App\Objects\RequestBuyer');
}


}
$requests = Request::with('buyers')->get();
这将返回一个json,其中包含买家集合的所有记录,但我希望在这个json响应中包含类别详细信息

我如何做到这一点?

请按照以下步骤操作:

$requests = Request::with('buyers', 'category')->get();
顺便问一下,
请求
类别
之间的关系是什么?

请执行以下操作:

$requests = Request::with('buyers', 'category')->get();

顺便问一下,
请求
类别
之间的关系是什么?

类别包含请求集合,请求包含买家集合类别包含请求集合,请求包含买家集合