did you specify the relations? can you show your models? something like
class Inspection extend Eloquent {
public function entries {
return $this->hasMany('Entries', 'id');
}
}
class Entries extend Eloquent {
public function inspection {
return $this->belongsTo('Inspection', 'id');
}
}
Thanks for the reply jrsalunga. Here are my models. The relationships for Inspection and InspectionEntry both work, entries just get stripped out when its converted to json.
class Inspection extends Eloquent {
public $timestamps = false;
protected $fillable = array("facility_id", "type", "score", "date", "comply_by", "complied_on");
protected $guarded = array("id");
protected $primaryKey = "id";
protected $table = "inspections";
public function facility(){
return $this->belongsTo("Facility", "facility_id", "id");
}
public function entries(){
return $this->hasMany("InspectionEntry", "inspection_id", "id")
->orderBy("violation", "desc");
}
}
class InspectionEntry extends Eloquent {
public $timestamps = false;
protected $fillable = array("inspection_id", "violation", "comment", "memo", "points");
protected $guarded = array("id");
protected $primaryKey = "id";
protected $table = "inspection_entries";
public function inspection(){
return $this->belongsTo("Inspection", "inspection_id", "id");
}
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community