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

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); $metadata = App\Metadata::find($url);
if ($metadata == null || ($metadata->expires_at !== null && $metadata->expires_at < now())) { if ($metadata == null || ($metadata->expires_at !== null && $metadata->expires_at < now())) {
$resolved = $resolver->resolve($url); $resolved = $resolver->resolve($url);
$metadata = App\Metadata::create([ $metadata = App\Metadata::updateOrCreate(['url' => $url], [
'url' => $url,
'title' => $resolved->title, 'title' => $resolved->title,
'description' => $resolved->description, 'description' => $resolved->description,
'image' => $resolved->image, 'image' => $resolved->image,