我正在尝试配置我的应用。
我有一条路线,一个小型控制器,一个雄辩的资源。
路线
Route::resource('lands', '\App\Http\Lands\LandController')->only(['index']);
控制器
public function index(Request $request)
{
$lands = Land::where('oculto', 0)->get();
return LandsResource::collection($lands);
}
资源
public function toArray($request)
{
$barrio = $this->neighbourhood()->first();
return [
'id' => $this->id,
'direccion' => $this->direccion,
'metrosCuadradosVendibles' => $this->metros_cuadrados_vendibles,
'zonificacion' => $this->zonificacion,
'descripcion' => $this->descripcion,
'prioridad' => $this->prioridad,
'neighbourhood_id' => $this->neighbourhood_id,
'descripcion' => $this->descripcion,
'fot' => $this->fot,
'frente' => $this->frente,
'fondo' => $this->fondo,
'video' => isset($this->video),
'imagenes' => $this->images->map(function ($value) {
return ['posicion' => $value->posicion, 'url' => $value->url, 'descripcion' => $value->descripcion];
}),
'barrio' => [
'barrio' => $barrio->name,
'ciudad' => $barrio->city->name,
'barrioId' => $barrio->id,
'cityId' => $barrio->city->id,
],
'esFavorito' => $this->isFavourite($request->user('api')), //Como no estoy usando el middleware para identificar al user tengo que especificar el 'api' guard
];
}
我尝试了一些发条分析,但结果确实令人困惑。看来我的代码与响应时间无关。
有人以前找到过类似的东西吗? 我可以说服哪些调查途径来找出问题所在?。