3
I have a problem. I need to return the values of a relationship, however, presents the following error:
ErrorException
Undefined property: Illuminate\Database\Eloquent\Collection::$fileServico
My code:
Fileclass.php
public function fileServico(){
return $this->hasMany('File');
}
Fileservico.php
public function file(){
return $this->belongsTo('File');
}
You can have multiple Fileservico for a Fileclass. What am I calling:
Reservacontroller.php
public function getIndex(){
return View::make('home')->with('file',FileClass::all()->fileServico);
}
Ewerton Melo, put in your question the two tables and the classes in full please! Your relationship is wrong, but as I don’t know the name of your
class
it is difficult to put the answer– user6026