$comment->user->name
$.ajax({
method: 'POST',
url: 'url',
success: function (data) {
var month=[];
var device=[];
$.each(JSON.parse(data), function(index, report)
{
month.push(report.month)
});
$.each(JSON.parse(data), function(index, name)
{
device.push(name.devices)
});
//Build chart
var ctx = document.getElementById('chart').getContext('2d');
regionChart = new Chart(ctx, {
// The type of chart we want to create
type: 'horizontalBar',
dataType:'json',
// The data for our dataset
data: {
labels: month,
datasets: [{
label: "Chart",
data: device,
}]
},
});
}
});
class Item extends Model
{
protected $fillable = ['name'];
public function category() {
return $this->belongsToMany('App\Category', 'category_items','item_id','category_id');
}
}
class Category extends Model
{
protected $fillable = ['title'];
public function item() {
return $this->belongsToMany('App\Item', 'category_items', 'category_id', 'item_id');
}
}