I'm a front-end developer that has been asked to do some Laravel adjustments so please bear with me.
This is the code I'm trying to modify -
$location = Location::where('id', $id)->with('plants')->get(); $plantId = PlantLocation::where('location_id', $id)->get('plant_id'); $plants = Plant::whereIn('id', $plantId)->orderBy('id', 'asc')->get();
The DB has 4 tables - Participants(users), Locations, Plants, Plant Locations. There are relationships between them.
On the form first you select the Participant, the DB is queried and you get a list of Site tied to the Participant. Then you choose a Site and get a list of Plants tied to the Site.
So far everything works well with no issues. Here's what I need to update.
In the Plants Location table say I have 3 unique Plants tied to a Site - Rose, Tulip, Orchid, everything works fine and I see [Rose, Tulip, Orchid] in the Plants dropdown.
But if I have the >1 (greater than 1) of the same plant tied to a site (example Rose, Tulip, Rose), I see [Rose, Tulip]. What I want is [Rose, Tulip, Rose] as my output.
Can someone point me in the right direction please? Thank you!