Hello,
I'm calling a JSON API via HTTP then returning the data to my view. Within the view, there is the option to add an item from the API to a DB. I've got this working fine. The bit I'm unsure how to do or approach is excluding the DB entries from showing when I call the API again.
Here's my controller
public function listTopicsFromAPI()
{
$response = Http::get('https://example.com/topics.json/search');
$topics = $response->json();
return view('admin.approve-topics', compact('topics'));
}
At some point in this function, I'm guessing I need to check my DB and compare to the API then exclude the items before presenting them back to the user.
The data returned from the API is an array of arrays and I need to check against the Title. I've removed all the junk from the API dump so there's less to read for you.
array:25 [▼
0 => array:21 [▼
"Id" => "Topic title",
"Title" => "Topic title"
]
]
Is array_filter the best approach?