选择脚本中的位置

时间:2018-10-19 16:44:27

标签: php mysql html-lists

我有一个脚本,可以根据日期选择事件,但是我想实现根据我创建的称为用户的列进行选择的条件。

<?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(),但是它返回错误。

0 个答案:

没有答案