I am trying to integrate fullcallendar in a laravel10 + Metronic app
helpers.addVendors(['fullcalendar']);
called from controller gives error:
Undefined constant "AppHttpControllershelpers"
CODE:
<?php
namespace AppHttpControllers;
use AppModelsUser;
use IlluminateHttpRequest;
class CalendarController extends Controller
{
public function index()
{
helpers.addVendors(['fullcalendar']);
return view('pages/calendar')->with(['page'=>'calendar','section'=>'this_month']);
}
}
How to add assets from controller? Documentation isn’t that clear.
Thank you.
2
Answers
I found it by myself. What you got to do is go to
laravel_app/config/global/pages.php
and add this to the main array :Create a route
Create a controller
Create
calendar.blade.php
inlaravel_app/resources/views/pages/
and add calendar and modals from the demo1 calendar.htmlThat is all, hope it helps others, as the Metronic documentation on laravel is not that clear.
You should never add assets from your controller. Code you used is not PHP/laravel code, so it won’t work.
You should always add assets in your blade file, in this case with script tag like this:
Then you can use fullcalendar as it’s official documentation suggests https://fullcalendar.io/docs/initialize-globals