现在我有一个包含gender,options和user_id的表单.我public function store (Request $request)看起来像这样:
public function store(Request $request)
{
$task = new Appointment;
$task->gender = $request->gender;
$task->options = $request->options;
$task->user_id = $request->user_id;
$task->save();
}
Run Code Online (Sandbox Code Playgroud)
这完全没问题,但这只是3个字段?最终我希望我的表格大5倍.我的功能将是巨大的.有没有办法用更少的代码保存一切?
我发现了这个:$data = Input::all();
这会获取所有数据,但我不知道如何将其保存在数据库中.
每次我去我的项目时,我都会收到一个 502 错误的网关。当我刷新时,页面工作。如果我点击另一个页面的链接,我会再次收到 502 bad gateway。刷新后页面加载。这里可能有什么问题。
Homestead.yaml
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: c:/Users/MyNameHere/.ssh/id_rsa.pub
keys:
- c:/Users/MyNameHere/.ssh/id_rsa
folders:
- map: c:/Users/MyNameHere/Desktop/sites
to: /home/vagrant/code
sites:
- map: spa.test
to: /home/vagrant/code/spa/public
databases:
- homestead
Run Code Online (Sandbox Code Playgroud)
获得了 virtualbox 和 vagrant 的最新版本。
我的 spa 文件夹包含最新版本的 Laravel。
是否可以从组件外部调用方法以使组件可重用?
现在,我添加我的按钮以在模板插槽中打开模态:
index.php
<modal>
<template slot="button">
<button class="btn">Open modal</button>
</template>
Some modal text
</modal>
Run Code Online (Sandbox Code Playgroud)
Modal.vue
<template>
<div>
<div @click="showModal"><slot name="button"></slot></div>
<div v-if="showingModal"><slot></slot></div>
</div>
</template>
<script>
export default {
data () {
return {
showingModal: false,
}
},
methods: {
showModal() {
this.showingModal = true;
},
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
我觉得有更好的选择,但我不知道。
如何将数据分配给动态变量。
我想要实现的是:
我的 vue 数据变量:
test: '',
Run Code Online (Sandbox Code Playgroud)
添加点击
<div @click="assignData(test)"
Run Code Online (Sandbox Code Playgroud)
方法:
assignData(value) {
// Now I don't want this
this.test = 'lorem..';
// Instead I want something like this
value = 'new value for test';
// Or
this.value = 'new value for test';
}
Run Code Online (Sandbox Code Playgroud)
现在显然这行不通,但我希望你能明白。
我需要更改许多变量,我不想像这样在函数中添加所有变量
assignData(value) {
this.test = 'lorem..';
this.anotherVar = 'ipsum';
this.newTest = '....';
}
Run Code Online (Sandbox Code Playgroud) 首先,我检查是否支持Localstorage,如果是,我检查localstorage中是否有项目查询.如果有项目,则应更新为查询状态.在setState之前,我有一个警报,它会提醒项目.但是在setState之后我再次提醒但它什么都没显示?有人知道为什么吗?即使我this.setState({query: localStorage.getItem("query")})用this.setState({query: 'test'})它取代它也不会在警报中显示测试?
getLocalStorage = () => {
if (typeof(Storage) !== "undefined") {
if (localStorage.getItem("query") !== null) {
//Alerts 'a string'
alert(localStorage.getItem("query"));
this.setState({
query: localStorage.getItem("query")
});
//Alerts nothing?
alert(this.state.query);
this.search();
}
else{
this.getLocation();
}
}
else {
this.getLocation();
}
};
Run Code Online (Sandbox Code Playgroud) 是否有可能使v-for数组成为动态?像这样:
<div v-for="(company, index) in arrayName">
....
</div>
Run Code Online (Sandbox Code Playgroud)
数据:
data() {
return {
companies: [],
arrayName: 'companies'
}
},
Run Code Online (Sandbox Code Playgroud) 现在,如果我转到http:// localhost:8000/config.php,它告诉我:安装并启用intl扩展(用于验证器).
所以我做的是:
检查过/etc/php/7.0/cli/php.ini哪个文件;extension=php_intl.dll
安装symfony/intl在composer.json
并且仍然获得安装和启用intl扩展的建议.
javascript ×3
vue.js ×3
laravel ×2
php ×2
homestead ×1
reactjs ×1
symfony ×1
vagrant ×1
virtualbox ×1