You are meant to pass data down. Not call controllers from a blade component. So send that data inside the component or pass it in as data
Feb 18, 2023
19
Level 1
Calling Controller functions in blade tempalte
Hello guys, I'm new to Laravel and I'm trying to call a Controller function from a blade template. I'm doing something definitely wrong.
Controller
class MenuController extends Controller
{
public function getMenu(){
dd(Prompt::all('service'));
}
}
Blade template
{{ action([\App\Http\Controllers\MenuController::class, 'getMenu']) }}
Level 102
@danilotrix so is that menu in your layout? If so, you might want to use a view composer to pass that data https://laravel.com/docs/9.x/views#view-composers
Please or to participate in this conversation.