this is what blade is for.
besides, you cant have two return statements ? Only the first would be actioned.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Is there a way to have a class method return a Flux component? My work around was to create my own blade component to hold the Flux tags then return view('my-flux-component'). But can I just call Flux directly without concatenating a string in the method?
For example, I have a list of Posts I want to add an action menu: View, Delete, etc. I want to have an action class that handle() but also render the menu item.
// Example
class Post
{
public $actions = [
Actions\ViewPost::class,
Actions\DeletePost::class
];
}
//Example
class Actions\ViewPost
{
public static function menuItem()
{
// What I'm trying to achieve
return Flux::menuItem( $attributes... );
// or...
return view('flux::menu.item', [...]);
}
}
Please or to participate in this conversation.