i am stuck with eloquent and laravel.
any help would be appriciated.
setup:
posts_table
id | name | desc...
photos_table
id | post_id | image_path
posts model
public function photo()
{
return $this->hasOne('App\Photo');
}
photos model
public function posts()
{
return $this->belongsTo('App\Flyer');
}
i want to fetch all posts and only one image that belongs to each post, because there can be more images per post. cant create this with eloquent or db builder.
edit: one more q :)
and how to get only desired columns, like posts_table.name and photos_table.image_path