我有一个根据日期选择事件的脚本,但是我想实现一个条件,根据我创建的名为user的列来选择。
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Event;
use MaddHatter\LaravelFullcalendar\Facades\Calendar;
class EventController extends Controller
{
public function index()
{
$events = [];
$data = Event::all();
if($data->count()) {
foreach ($data as $key => $value) {
$events[] = Calendar::event(
$value->title,
true,
new \DateTime($value->start_date),
new \DateTime($value->end_date.' +1 day'),
null,
// Add color and link on event
[
'color' => '#ff0000',
'url' => 'pass here url and any route',
]
);
}
}
$calendar = Calendar::addEvents($events);
return view('home', compact('calendar'));
}
}
我已经检查过是否应该使用event:find()而不是event::all(),但是它返回了错误。
暂无答案!
目前还没有任何答案,快来回答吧!