I have two models. My first one is:
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Fixture extends Model {
public function match()
{
return $this->hasOne('App\Matchinfo');
}
public function result()
{
return $this->hasOne('App\Result');
}
}
and the second one:
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Matchinfo extends Model {
protected $table = 'matchinfo';
public function fixture()
{
return $this->belongsTo('App\Fixture');
}
}
When I run $fixture = Matchinfo::where('mdate','<','NOW()')->get(); it picks up the data just fine. However when I then try $fixture->fixture()->where('id','fixture_id')->get(); all I get is
FatalErrorException in DynamicPagesController.php line 15: Call to undefined method Illuminate\Database\Eloquent\Collection::fixture()
I'm new to relationships in eloquent so I'm really stuck. It looks like it should be ok. Can someone point me in the right direction please?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community