LaravelCalendar
LaravelCalendar copied to clipboard
Problem and solution for using segments = true
This is a good calendar package, just want to share the problem encountered and how to solve it. If you set segment to true and have problem navigating to the next or prev month due to duplicated year and month parameters url.
In vendor\gloudemans\calendar\src\Gloudemans\Calendar, change line 26 from $this->next_prev_url = $request->url(); to $this->next_prev_url = $request->root().'/'.$request->segment(1);
@meltz: Your solution only works when the calendar is on a page that has a URL that consists of only a single segment. It'd be handy if there were a config option for setting the base url of the page that the year and month parameters get appended to. I'll try to find time to put together a pull request soon.
try this code... i use this code in CI and Laravel
public function calendar($y = null, $m = null){
$config = array('show_next_prev' => true,
'next_prev_url' => url('calendar'),
'segments' => true);
Calendar::initialize($config);
echo Calendar::generate($y, $m);
}