Can someone help me how do I pass this function in Vue "props"?
public function showBusinessIntelligenceModule($store_id = NULL) {
$stores = Stores::findOrFail($store_id);
$reportParams = array(
'date_from' => date('Y-01-01') . " 00:00:00",
'date_to' => date('Y-12-t') . " 23:59:59",
'store_id' => $store_id,
'sku' => ''
);
$dashboard_rules = DashboardManagement::select('role_id', 'is_visible')
->where('role_id', \Auth::user()->role_id)
->where('dashboard_id', 2)
->get();
$latestBusinessReportFile = BusinessReportFiles::getLatestRecord($store_id);
$businessReportDate = $latestBusinessReportFile ? date('Y-m-d', strtotime($latestBusinessReportFile->created_at)) : date('Y-m-d');
$inventory_forecasts = DB::table('restock_inventories', $store_id)
->join('product', function($join){
$join->on('restock_inventories.product_id', '=', 'product.id');
})
->where('product.store_id', $store_id)
->where('product.sku_type', '!=', 'Old Inactive')
->where('restock_inventories.days_of_supply', '<', 14)
->select('product.sku', 'restock_inventories.days_of_supply')
->groupBy('product.sku')
->paginate(10);
// print_r($inventory_reports);
$data = [
'active' => 'store_dashboard',
'active_view' => 'bim',
'content_visibility'=>$dashboard_rules[0]['is_visible'],
'store_id' => $store_id,
'stores' => $stores,
'report_params' => $reportParams,
'latestBusinessReportDate' => $businessReportDate,
'restock_inventories' => $inventory_forecasts
];
return view('stores_dashboard.bim')->with($data);
}
sorry I missed other part of the code. I am trying to get the latestBusinessReportDate from this code and pass it in vueJS props. in blade file, i am getting an actual date. but im not sure how to get it in vue. this is my vue file btw,
<template>
<Modal @close="doClose">
<template v-slot:container class="notifications">
<section class="card forecast-vue-modal-container">
<header class="card-header">
<h2>Days of Supply as of {{ latestBusinessReportDate }}</h2>
<!-- <span class="custom-close fa fa-times" @click="doClose"></span> -->
</header>
<div class="card-body">
<table>
<thead>
<th>SKU</th>
<th>DAYS OF SUPPLY</th>
</thead>
<tbody>
<tr v-for='(item, index) in data' :key='index'>
<th v-if="('SKU')">{{ item.sku }}</th>
<th v-if="('DAYS OF SUPPLY')">{{ item.days_of_supply }}</th>
</tr>
</tbody>
</table>
</div>
<footer class="card-footer">
<div class="btn-group ml-auto float-right">
<button type="button" class="btn btn-secondary btn-close" @click="doClose">Close</button>
</div>
<!-- -->
</footer>
</section>
</template>
</Modal>
</template>
<script>
import Modal from "../Reusable/Modal";
export default {
components: {
Modal,
},
data() {
return {
errors: {},
name: '',
};
},
props: {
data: {
type: Array,
required: true,
},
},
methods: {
doClose() {
this.errors = {};
this.name = '';
this.$emit('close');
},
}
}
</script>
this data appears in a modal.