데이터베이스에서 여러 데이터를 반환하는 json과 작업 중이며 관계가없는 정수 모델을 반환해야합니다. LampModels이이 위대한 json으로 모델링 한 모든 레코드를 반환하십시오. 하지만 Laravel은 항상 나를 돌려줍니다. 잘못된 오프셋 유형입니다.Laravel return 모델을 반환 할 때 잘못된 오프셋 형식을 사용합니다.
컨트롤러
public function showAllUdiJson()
{
$allLamps = LampModels::all();
return Ilumination::with('street')
->with('neighborhood')
->with('iluminationinfo')
->with('economyplan')
->with('lamp')
->with('reactor')
->with('aluminumcable')
->with('steelconduit')
->with('alllamps', $allLamps)
->with('ticket')->get();
}
LampModels
<?php
class LampModels extends \Eloquent {
protected $fillable = [];
protected $table = 'lampmodel';
}
조명
<?php
class Ilumination extends \Eloquent {
protected $fillable = [];
protected $table = 'ilumination';
public function street()
{
return $this->belongsTo('street');
}
public function neighborhood()
{
return $this->hasOne('neighborhood', 'id');
}
public function iluminationinfo()
{
return $this->hasOne('iluminationinfo');
}
public function ticket()
{
return $this->hasMany('ticket');
}
public function economyplan()
{
return $this->hasOne('economyplan', 'id' ,'street_id');
}
public function lamp()
{
return $this->hasOne('lamp', 'id');
}
public function reactor()
{
return $this->hasOne('reactor', 'id');
}
public function aluminumcable()
{
return $this->hasOne('aluminumcable', 'id');
}
public function steelconduit()
{
return $this->hasOne('steelconduit', 'id');
}
}
오류 메시지의 전체 텍스트/추적을 공유하십시오. 'LampModels'과'Ilumination' 클래스를 보는 것도 도움이 될 것입니다. –
@ThomasKelley 완료 – gmanara