maddhatter / laravel-fullcalendar

Laravel FullCalendar.io Helper
627 stars 267 forks source link

Too few arguments to function #144

Closed fadzilahariffin closed 5 years ago

fadzilahariffin commented 5 years ago

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_RECOVERABLE_ERROR) Too few arguments to function Illuminate\Database\Eloquent\Model::setAttribute(), 1 passed in...

Model class Event extends Model { protected $table = 'events'; protected $guarded = []; protected $fillable = [ 'title', 'color', 'start_date', 'end_date' ]; }

Controller public function create(){ $events = Event::all(); $event = []; foreach ($events as $event) { $event[] = \Calendar::event( $event->title, //event title true, //full day event? new \DateTime($event->start_date), //start time, must be a DateTime object or valid DateTime format (http://bit.ly/1z7QWbg) new \DateTime($event->end_date), //end time, must be a DateTime object or valid DateTime format (http://bit.ly/1z7QWbg), $event->id, //optional event ID [ 'color' => $event->color, ] ); } // dd($events);

    $calendar = \Calendar::addEvents($event);

    return view('event.create',compact('calendar'));
}

DB Schema::create('events', function (Blueprint $table) { $table->increments('id'); $table->string('title'); $table->string('color'); $table->dateTime('start_date'); $table->dateTime('end_date'); $table->timestamps(); });