Sage 10, Composer controller on ACF block

Hello,
I’m trying to create a composer controller on a ACF block, this is the code

resources/views/blocks/latest-news.blade.php
{{–
Title: Latest news
Description: Latest news Block
Category: formatting
Icon: wordpress
Keywords: news
Mode: edit
–}}

@php var_dump($test); @endphp

app/View/Composers/Blocks/LatestNews.php

namespace App\View\Composer\Blocks;
use Roots\Acorn\View\Composer\Blocks;
 
class LatestNews extends Composer
{  
    /**
     * List of views served by this composer.
     *
     * @var array
     */ 
    protected static $views = [ 
        'blocks.latest-news', 
    ];
 
    public function with()
    {  
        return [ 'test' => 'Hello' ];
    }  
} 

but I get an error that $test has not been declared so it seems that it does not enter the LatestNews class.
Do you see something wrong?

acf-composer should make your life easier.

This topic was automatically closed after 42 days. New replies are no longer allowed.