Metadata.expires_atをCarbon化

This commit is contained in:
shibafu 2019-01-16 00:15:41 +09:00
parent acb9b5821d
commit 810eea2a59
2 changed files with 3 additions and 1 deletions

View File

@ -12,4 +12,6 @@ class Metadata extends Model
protected $fillable = ['url', 'title', 'description', 'image', 'expires_at'];
protected $visible = ['url', 'title', 'description', 'image', 'expires_at'];
protected $dates = ['created_at', 'updated_at', 'expires_at'];
}

View File

@ -26,7 +26,7 @@ Route::get('/checkin/card', function (Request $request, MetadataResolver $resolv
$url = $formatter->normalizeUrl($request->input('url'));
$metadata = App\Metadata::find($url);
if ($metadata == null || ($metadata->expires_at !== null && new DateTime($metadata->expires_at) < new DateTime("now"))) {
if ($metadata == null || ($metadata->expires_at !== null && $metadata->expires_at < now())) {
$resolved = $resolver->resolve($url);
$metadata = App\Metadata::create([
'url' => $url,