Hello everyone,
I am using laravel's eloquent for my website and I want to get all the data from a table in my database. Now don't seem to get it working.
Could somebody tell me what I am doing wrong.
Here are my codes :
<?php
// Controller
/**
* Get all tasks from the database.
* @return null, Does not return anything.
*/
public function getTasks() {
echo Task::all();
}
// END CONTROLLER
// BEGIN MODEL
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'tasks';
public function __construct() {
parent::__construct();
}
?>
And here is my jquery :
/**
* Get all tasks from the database.
* @return {json string} Get all the tasks from the database.
*/
TASK.getAll = function(d) {
$.get("/dashboard/tasks/get_tasks/", function(o) {
for (var i = 0; i < o.length; i++)
{
$(d).append(
'<li> ' +
'<label><span class="task-description">' + o[i]->taskTitle + '</span> <span class="label label-' + o[i].taskColor + '">' + o[i].taskLabel + '</span></label>' +
'<div class="options todooptions ng-scope">' +
'<div class="btn-group">' +
'<button class="btn btn-default btn-xs" onclick="complete(this, item)" rel="'+o[i].id+'"><i class="fa fa-fw fa-check"></i></button>' +
'<button class="btn btn-default btn-xs" onclick="edit(item)" rel="'+o[i].id+'"><i class="fa fa-fw fa-pencil"></i></button>' +
'<button class="btn btn-default btn-xs" onclick="TASK.deleteTask(this)" rel="'+o[i].id+'"><i class="fa fa-fw fa-trash-o"></i></button>' +
'</div>' +
'</div>' +
'</li>');
}
}, 'json');
};
Note that I am leaving out the code that has nothing to do with this.
How can I fix this ?
Not laravel, but have a look. http://simplemvcframework.com/forum/viewtopic.php?f=1&t=2040&p=2403&hilit=json#p2377
In laravel you response, not echo.
@jimgwhit I am actually using parts of laravel for my own system.
I will try to get it working tomorrow.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community