I have a function like this:
public function entity($entity_id, Request $request)
{
$expiresAt = Carbon::now()->addMinutes(10);
$entity = Cache::remember('entities', $expiresAt, function () {
return Entity::where('id', $entity_id)
->with('address')
->with('_geoloc')
->first();
});
However this returns an error saying, $entity_id is undefined, however when I do dd($entity_id) after $expiresAt, it is defined as I get the id back, id comes from url if that is needed.