Blade – keep login in controller

Another Blade question…

I like to grab all my AFC fields with get_fields(), store them in an array, then access them from there rather the individually calling get_fields() many times.

For example:

$fields = get_fields();

<h2><?= $fields['sub_header'] ?></h2>
<img src="<?= $fields['image']['url'] ?>" alt="<?= $fields['image']['alt'] ?>">

I’m trying to replicate this in Blade. However, I’m struggling a little with keeping all the logic in the controller.

If I call get_fields within the controller, I then can’t manipulate the data within my view:

class TemplateContact extends Controller

    public function fields()
        return get_fields();


For example, if I need to use urlencode something within a field, normally I would:

$location = urlencode($fields['map']['address']);

But if I pass the fields to the view as above, I’m then stuck with the values as they are. I’m sure I can do more in the controller. Or am I just going about this all wrong? Please send help #noob.