【发布时间】:2014-05-31 22:04:54
【问题描述】:
我正在 Laravel 上学习 AngularJS,我正在制作一个简单的应用程序。到目前为止,该应用程序在已完成区域或未完成区域中显示数据库中的行。如果用户单击该项目,它会移动到对面的区域。
$scope.move = function(item) {
item.has_item = !item.has_item;
};
以上内容会在点击时移动项目,但是为了持久性,我添加了:
$scope.move = function(item) {
var newState = !item.completed;
$http.post('/items', item).success(function() {
item.completed = newState;
});
};
现在,我只需要一条路由来接受这篇文章并将完成的更新值插入数据库。
我试过了:
Route::post('items', function()
{
$completed = Input::get('completed');
return $completed->push();
});
但是,我没有运气。我需要做什么才能将值插入数据库?
【问题讨论】:
-
$completed将 not 是一个对象,它将是一个字符串(如果不存在,则为 null)。当您没有使用 Laravel 进行任何适当的数据库调用时,很难回答您。
标签: php ajax angularjs laravel eloquent