$activity = new Activity();
$activity->location_id = $location->id;
$activity->booked_start = $dateFrom->format(DbConfig::SQL_DATETIME_FORMAT);
$activity->booked_end = $dateTo->format(DbConfig::SQL_DATETIME_FORMAT);
$activity->name = $name;
$activity->description = $description;
$activityResources = [];
foreach ($resources as $resourceId => $amount) {
$activityResource = new ActivityResource();
$activityResource->resource_id = $resourceId;
$activityResource->amount = $amount;
$activityResources[] = $activityResource;
}
$activity->activityResources = $activityResources;
$this->session->activity = $activity;
And now at another pageload in some controller:
$this->session->activity->save();
Only the activity itself is saved in the DB. The ActivityResources are not. If I save right away, they do get saved. Is this intended behaviour or is this a bug? Could there be a workaround?