Closed dreamfast closed 7 months ago
Actually the solution for this was rather simple and I had had overridden the drag and drop event here - https://github.com/saade/filament-fullcalendar/blob/3.x/src/Widgets/Concerns/InteractsWithEvents.php
Originally the documentation assumes there is just one Model type Event
. Having more than one Model type and having some custom code to parse the events and save them works much better.
This is what I had ended up using.
public function onEventDrop(array $event, array $oldEvent, array $relatedEvents, array $delta): bool
{
$model = null;
switch ($event['extendedProps']['calendar_type']) {
case 'job':
$model = Job::findOrFail($event['id']);
$model->deadline_date = Carbon::parse($event['end']);
break;
case 'job-task':
$model = JobTask::findOrFail($event['id']);
if ($event['end']) {
$model->end_date = Carbon::parse($event['end']);
}
break;
}
$model->start_date = Carbon::parse($event['start']);
$model->save();
return false;
}
Hi, thanks for making this plugin!
I've followed the readme and I'm trying to update the dates on drag and drop.
I have a Calendar page which has the
CalendarWidget.php
I have at the top
public Model | string | null $model = JobTask::class;
, although have tried with and without it. I am hoping to target many models, let me know if this is an issue.Using
use Saade\FilamentFullCalendar\Actions;
I get the errorTyped property Saade\FilamentFullCalendar\Widgets\FullCalendarWidget::$record
, with no model updates.Using
use Filament\Actions;
it will work, although haveApp\Filament\Dashboard\Widgets\CalendarWidget::App\Filament\Dashboard\Widgets\{closure}(): Argument #1 ($record) must be of type Illuminate\Database\Eloquent\Model, null given, called in /var/www/laravel/vendor/filament/support/src/Concerns/EvaluatesClosures.php on line 35
after the event has finished.I am using this code, note for the arguments I had appended
|null
for theuse Filament\Actions;
to work. Without them there is an error thrown as they do not exist.I figured it's best to use
use Saade\FilamentFullCalendar\Actions;
but I must be overlooking something or missed a step with the setup. This is theCalendarWidget.php
file. Note I had tried to work around this by using the switch and find model statements, but no luck.