メタデータの更新時に多重登録されないようにした

This commit is contained in:
shibafu 2019-01-16 00:17:43 +09:00
parent 810eea2a59
commit cd26ef6236

View File

@ -28,8 +28,7 @@ Route::get('/checkin/card', function (Request $request, MetadataResolver $resolv
$metadata = App\Metadata::find($url);
if ($metadata == null || ($metadata->expires_at !== null && $metadata->expires_at < now())) {
$resolved = $resolver->resolve($url);
$metadata = App\Metadata::create([
'url' => $url,
$metadata = App\Metadata::updateOrCreate(['url' => $url], [
'title' => $resolved->title,
'description' => $resolved->description,
'image' => $resolved->image,