我试图在localhost(vagrant和virtualbox)上使用Laravel和sqlite DB编写一个简单的登录表单.但是,在输入用户名和密码后,我不断收到"PDOException找不到驱动程序"错误.有任何想法吗?
---编辑---
必须通过键入来安装sqlite驱动程序
sudo apt-get install php5-sqlite
Run Code Online (Sandbox Code Playgroud)
在我的终端窗口.默认情况下它没有启用:/
试图为Morris.js圆环图创建一个JSON数组,但无法想出任何获得正确格式的方法.有小费吗?
我的控制器:
$user = User::find((Auth::user()->id));
$budget = $user->budget()->get();
$labels = ['rent', 'heating', 'utilities', 'internet_tv', 'phone', 'food', 'sweets', 'alcohol_cigs', 'insurance' , 'loans', 'finance_other', 'cosmetics'
, 'medicine', 'clothes_shoes', 'accessories', 'electronics', 'school', 'entertainment', 'food_out', 'holidays', 'books', 'pets', 'gifts', 'car', 'other'];
$data2 = [];
foreach ($labels as $label)
{
$data2['label'][] = $label;
$data2['value'][] = $budget->sum($label);
}
$data2 = json_encode($data2);
Run Code Online (Sandbox Code Playgroud)
我得到了什么:
'{"label":["rent","heating","utilities","internet_tv" ...],"value":[435,30,0,0 ...]}'
Run Code Online (Sandbox Code Playgroud)
我想得到:
'[{"label":"rent","value":"435"},{"label":"heating","value":"30"},{"label":"utilities","value":"0"},{"label":"internet_tv","value":"0"} ...]'
Run Code Online (Sandbox Code Playgroud)