So I have two tables Animals and Adoptions
The animal table holds [animalID, name, DOB]
Adoptions hold [id, animalID, userID, approved]
I need to write a statement which would match the animalID in both the tables and would return the name and DOB of the animal where approved is 0.
I have hardly any previous experience with either mySQL or Laravel so my assumption would be that the SQL query would look like this:
SELECT animalName, DOB
FROM animal
INNER JOIN
Adoption ON adoption.animalID = animal.animalID
WHERE
Adoption.approved = 0
Currently I am returning all of the animals in the table. So I need to add the join and do the checking to see if the animalID in the adoptions table has a value of 0
public function available ()
{
//JOIN ANIMAL AND ADOPTION TABLES
//RETURN ALL ANIMALS WHERE APPROVED = 0
$animalQuery = Animal::all();
return view('/available', array('animals'=>$animalQuery));
}