I have two tables let me show you what it looks like,
Projects
---------
id
Images
-------
id
projects_id
image
is_default
when uploading images for a project, multiple images are uploaded the default image isn't set yet. so when i run the query like this,
$projects = Project::leftJoin('images', 'projects.id', '=', 'images.project_id')->get();
so if i have 4 images listed in the images table and one record in the projects table, i get a result of 4 projects with the same information using all the different images i used for that project.
How can i Limit it to only show one project record that has is_default set to 1 and if none exists it would show a dummy image.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire