Function inside view

Hello,

I am using the .phtml template engine, and I would like to know if it possible to past custom functions into the view like function test(){ return 34; }

and then in the view $test = test(); echo $test;

AND is it posible to remove the findFirst function inside view?

First of all inside the view you should never do queries and programing logic; keep that to your controller.

To your view you should pass only your functions/queries result

So for your function test(), in your controller do $test = test(); and then

$this->view->setVars([
        'test' => $test
]);

Then in your view you'll be able to call your variable like:

$test - phtml
test - volt