Reading from the CDN
We now want Vuebnb to load any static assets from the CDN instead of the web server when in production. To do this, we're going to create our own Laravel helper method.
Currently, we reference assets in our app using the asset
 helper. This helper returns a fully-qualified URL for that asset's location on the web server. For example, in our app view we link to the JavaScript bundle file like this:
<script type="text/javascript" src="{{ asset('js/app.js') }}"></script>
Our new helper, which we'll call cdn
, will instead return a URL that points to the asset's location on the CDN:
<script type="text/javascript" src="{{ cdn('js/app.js') }}"></script>
CDN helper
Let's begin by creating a file called helpers.php
. This will declare a new cdn
 method which, for now, won't do anything but return the asset
 helper method.
app/helpers.php
:
<?php if (!function_exists('cdn')) { function cdn($asset) { return asset($asset); } }
To ensure this helper is available...