2016-07-22 4 views
0

データベースからいくつかのデータを返す大規模な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'); 
    } 
} 

See the error

+0

は、エラー・メッセージの全文/トレースを共有してください。 'LampModels'クラスと' Ilumination'クラスを見るのに役立つかもしれません。 –

+0

@ThomasKelley done – gmanara

答えて

0

あなたのエラーレポートは非​​常に悪いですが、と思われますあなたのイルミネーションモデルはオールランプ法を持っていません。

LampModelsをイルミネーションモデルにアタッチする必要があります

0

私はあなたがどこかにエラーが発生したオフセット照明モデルで作成されたチケットメソッドにアクセスすると思います。..

public function ticket() 
{ 
    return $this->hasMany('ticket'); 
} 

あなたはillumination->チケットにアクセスしたい場合は、ループで、このメソッドを使用する必要があります。

foreach(illumination->tickets as ticket) { 
    $field1 = ticket->field1; 
} 

あなたはまだここにあなたのエラーログページを共有するよりもすべての問題に直面した場合は...

関連する問題