我想返回一个站点关闭时的日期时间范围数组.
我正在使用MySQL 5.7.
表 down_time
created_at user_id down
2017-12-15 14:50:21 1 1
2017-12-21 19:19:19 1 0
2017-12-25 22:41:14 1 1
2017-12-25 22:41:17 1 0
2017-12-25 23:11:22 1 0
2017-12-25 23:11:24 1 1
2017-12-25 23:31:24 1 1
Run Code Online (Sandbox Code Playgroud)
这里的向下列 - 0(假)表示向下,1(真)表示向上.我需要一个像这样的视图/结果:
down up user_id
2017-12-21 19:19:19 2017-12-25 22:41:14 1
2017-12-25 22:41:17 2017-12-25 23:11:24 1
Run Code Online (Sandbox Code Playgroud)
希望这个例子完全代表我的查询需求 - 我只需要停机时间范围.
如果可以实现使用Laravel(5.5)SQL查询辅助方法,那就太棒了(所以我可以很容易地附加查询选择器->where('user_id', Auth::user()->id)->whereBetween('created_at', [$range['from'], $range['to']])),但我在这种情况下并不挑剔 - 原始的MySQL(5.7.19)查询也会很棒.
我试图在 Laravel Vapor 中包含 php-gd 扩展,因为假设没有开箱即用。我需要这个包的扩展https://github.com/Maatwebsite/Laravel-Excel,我用它来导出 csv。
这是当composer尝试安装包时vapor在部署时返回的结果。
从这篇文章的暗示来看:
https://blog.laravel.com/vapor-adding-imagick-as-a-separate-lambda-layer
我知道我需要使用或构建我自己的带有 php GD 扩展的 lambda 层,这样我就可以将其作为额外的蒸气层包含在内,但还不太确定如何做到这一点。
我的 B 计划只是将我的 Laravel 应用程序安装在专用 VPS(例如 EC2)上,并提供软件包和 php-gd,我可以将其用作服务。
使用参数时如何观察存储值的变化?我通常会通过 getter 来做到这一点,但我的 getter 接受一个参数,这使得它变得棘手,因为我未能找到有关此场景的文档或堆栈 Q/A。
(出于演示原因,代码被最小化)我的 store.js :
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
let report = {
results: [],
};
export const store = new Vuex.Store({
state: {
broken: Object.assign({}, report),
},
results: (state) => (scan) => {
return state[scan].results
},
});
Run Code Online (Sandbox Code Playgroud)
vue-component.vue :
computed: {
...mapGetters([
'results',
]),
watch: {
results(){ // How to pass the param ??
// my callback
}
Run Code Online (Sandbox Code Playgroud)
所以基本上我想找出如何传递参数以便我的手表工作。
尝试重用 Graph.vue 文件中的自定义模板,但此尝试失败(控制台中没有任何错误)。我只渲染了一张图表(红色的)。有什么想法如何修复此代码吗?
我当前的代码如下所示:
main.js
import Vue from 'vue';
import Graph from './components/Graph.vue';
new Vue({
el: 'graph',
components: { Graph }
});
Run Code Online (Sandbox Code Playgroud)
图.vue
<template>
<canvas height="400" width="600"></canvas>
</template>
<script>
import Chart from 'chart.js';
export default {
props: ['labels', 'values', 'color'],
props: {
labels: {},
values: {},
color: {
default: 'rgba(220,220,220,0.2)'
}
},
mounted(){
var data = {
labels: this.labels,
datasets: [
{
label: "My First dataset",
fill: true,
lineTension: 0.1,
backgroundColor: this.color,
borderColor: "rgba(75,192,192,1)",
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0, …Run Code Online (Sandbox Code Playgroud) laravel ×3
vue.js ×2
aws-lambda ×1
browserify ×1
chart.js ×1
eloquent ×1
javascript ×1
mysql ×1
mysql-5.7 ×1
php ×1
sql ×1
vuejs2 ×1
vuex ×1