我使用了这个https://fullcalendar.io/完整日历jquery插件。
我有事件表,我可以获得如下事件:
public function index()
{
$events=Event::all();
return view('index')->with('events',$events);
}
$event->event_date
和$event->name
会提供活动日期和活动名称。我需要将事件名称添加到日历中的相应日期吗?
我试过这个:
$('#calendar').fullCalendar({
events:[
{
title:'{{$events[0]->name}}',
start:'{{$events[0]->event_date}}'
}
]
});
这只会给出数组中的第一个事件。但是,我怎样才能获得所有活动而不只是一个?因为title
数组中没有start
和$events
?或者基本上我只需要一个循环?
答案 0 :(得分:1)
import numpy as np
#convert the list of tuples l_tuples to a numpy array:
l_new = np.array(l_tuples)
#calculate the mean and standard deviation of the first column
mean=np.mean(l_new,axis=0)[0]
std=np.std(l_new,axis=0)[0]
#create a mask to find all elements which are in the interval [mean-std, mean+std]
mask=[abs(x[0]-mean)<std for x in l_new]
#pictures you want to use:
accepted = l_new[mask]
#pictures you dont want to use:
remove = l_new[[not i for i in mask]]
在您的刀片模板中
public function index()
{
$events=Event::all();
$keyed = $collection->mapWithKeys(function ($item) {
return ['title' => $item['name'], 'start' => $item['event_date']];
});
return view('index')->with('events',$keyed);
}