I read this article after upgrading my local dev environment to php8.
And implement it in my class, like:
<<Attribute('foo')>>
public function index()
{
$posts = (new Post)->get()->withMany('image');
return $this->app()->view('index', compact('posts'));
}
and it return error.
syntax error, unexpected token "<<", expecting "function" or "const"
What is really a proper of doing that in php8. Am i missing something?
To clarify why people might find examples with the wrong syntax: there was a lot of debate about what to use, and it was actually changed several times during the pre-release period of PHP 8. So, for some pre-8.0.0 builds,
<<Attribute>>
was in fact the correct syntax.