Я пытаюсь создать таблицу данных очень быстро и легко, но она не работает ..
Я использую Vuetify и Laravel.
Я построилLocationController:
public function index()
{
//
$locations = \App\Location::all();
$locations->toJson();
return view('locations.index', [
'locations' => $locations
]);
}
и в моем Blade-файле я хочу получить эти данные:
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Locations</div>
<datatable :laravel='{{ $locations }}'></datatable>
<div class="card-body">
</div>
</div>
</div>
</div>
</div>
@endsection
Затем в моем компоненте Datatable.vue я хочу выплюнуть:
<template>
<v-data-table
:headers="headers"
:items = "locations"
:laravel = "laravel"
class="elevation-1"
>
<template slot="items" slot-scope="props">
<td>{{ props.item.name }}</td>
<td class="text-xs-right">{{ props.item.city }}</td>
</template>
</v-data-table>
</template>
<script>
export default {
data () {
return {
headers: [
{
text: 'Name',
align: 'left',
sortable: false,
value: 'name'
},
{ text: 'City', value: 'city' },
],
locations: [],
laravel: [],
mounted()
{
console.log(datatable);
console.log(this.locations);
},
}
}
}
</script>
миграция местоположения_таблицы
public function up()
{
Schema::create('locations', function (Blueprint $table) {
$table->increments('location_id');
$table->string('name');
$table->string('postal_code');
$table->string('address');
$table->string('house_number');
$table->string('city');
$table->string('phone');
$table->string('mobile');
$table->string('email');
$table->string('website')->nullable();
$table->timestamps();
});
}
Я не могу узнать, как адресовать свои данные в этот vuetify datatable.Кто-нибудь может мне помочь с этим?