4

I have a route on the site that is to a webcal resource so we would like the URL to be generated with webcal:// when using {{ URL::route('calendar') }} in the Blade template.

I tried adding a protocol option but this is ignored, so I guess there must be another way?

Route::get('/calendar.ics',
    [
        'as' => 'calendar',
        'uses' => 'EntityController@calendar',
        'protocol' => 'webcal'
    ]
);

Suggestions welcome!

Space
  • 2,022
  • 1
  • 19
  • 29
  • Are you sure `protocol` is an acceptable array key to pass here? – haakym Jun 09 '16 at 10:35
  • @haakym Doesn't seem to have any impact - no error but the protocol is still http. I just guessed this param as it seemed logical, but couldn't find any documentation to support it. – Space Jun 09 '16 at 10:41
  • Try to extend blade for your own method: https://laravel.com/docs/master/blade#extending-blade. Take a look at how the current `route()` helper works: https://github.com/laravel/framework/blob/5.2/src/Illuminate/Foundation/helpers.php#L605 then you can make a `webCalRoute()` method perhaps? – haakym Jun 09 '16 at 10:49

1 Answers1

0

The webcal URI are not official protocols. The webcal:// will actually be handed to another app as http://.

As suggested, you can either do your own helper for this or write the plain actual URI in your views.

You may also use the Content-Type: text/calendar header but I guess it won't be opened in another application.

corentingi
  • 195
  • 1
  • 7