So, I'm going to document what I did here because I woke up in the middle of the night with what I think was a pretty great idea.
For my needs, all I wanted was the route parameter (although this could be useful for things like the entire request or any other variable or property available to Laravel).
Step 1. Remove all VueJS routing stuff. It's not necessary for this use case (keep the vue-resource though).
Now my /resources/assets/js/app.js looks like this:
require('spark-bootstrap');
require('./components/bootstrap');
Vue.use(require('vue-resource'));
// Spin up the Vue instance
var app = new Vue({
mixins: [require('spark')]
});
/resources/assets/js/components/bootstrap.js is the same as the OP.
Step 2. For testing purposes, change the /resources/views/needs/show.blade.php to the following to show that what we'll build here works:
@extends('spark::layouts.app')
@section('content')
<needs-show :user="user" inline-template>
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Need</div>
<div class="panel-body">
<pre>ID: @{{ spark.route.id }}</pre>
</div>
</div>
</div>
</div>
</div>
</needs-show>
@endsection
Step 3. Add the current route parameters to a custom Spark JS variable in /resources/views/vendor/spark/layouts/app.blade.php like so:
<!-- Global Spark Object -->
<script>
window.Spark = <?php echo json_encode(array_merge(
Spark::scriptVariables(), [
'route' => Route::current()->parameters()
]
)); ?>;
</script>
Step 4. Profit.
Assumed: You know the route parameters are set via your routes file, so something like this would have to exist:
Route::get('/needs/{id}', [
'as' => 'needs.show',
'uses' => 'NeedsController@show',
]);
... and your controller would have to return the appropriate view:
public function show(Need $need)
{
return view('needs.show');
}
... and just for completeness, here's my /resources/assets/js/components/needs/show.js as well:
Vue.component('needs-show', {
props: ['user'],
data() {
return {
}
},
methods: {
},
mounted() {
},
});