Files
fewo-stommer/app/Channels/ICal/ICalExport.php
T
Lars 783068501c
Deploy FeWo mit PipelineManager / deploy (push) Successful in 2m33s
Generische iCal-Kanäle mit Bestandsklärung und sicheren Exporten bereitstellen
2026-10-27 17:14:45 +01:00

27 lines
838 B
PHP

<?php
namespace App\Channels\ICal;
use App\Models\Channel;
use Illuminate\Support\Facades\DB;
class ICalExport
{
public function __construct(private ICalFeed $feed, private ICalParser $parser) {}
public function build(Channel $channel): ?string
{
return DB::transaction(function () use ($channel): ?string {
$locked = Channel::query()->whereKey($channel->id)->lockForUpdate()->firstOrFail();
if ($locked->exportsOccupations()) {
$body = $this->feed->build($locked);
$this->parser->parse($body);
$locked->forceFill(['export_snapshot' => $body, 'export_snapshot_at' => now()]);
}
$locked->forceFill(['last_export_requested_at' => now()])->saveQuietly();
return $locked->export_snapshot;
});
}
}