I have a post with multiple images. But I want to only fetch images with PNG format. So I do this is post :
public function images() {
return $this->hasMany('App\ImagesModel','mapID','id');
}
public function oftype($query)
{
return
$query->where('type', '=', 'PNG');
}
But this is not working.
$post = Post::find($id);
$post->images()->oftype()->get();
Kindly help.
via kirobo