2021-01-28 05:25:14 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
use App\Status;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
|
|
class StatusLabelService
|
|
|
|
{
|
|
|
|
const CACHE_KEY = 'pf:services:status_label:_v0:';
|
|
|
|
|
|
|
|
public static function get(Status $status)
|
|
|
|
{
|
2021-01-29 01:42:15 +00:00
|
|
|
if(config('instance.label.covid.enabled') == false || !$status) {
|
2021-01-28 05:25:14 +00:00
|
|
|
return [
|
|
|
|
'covid' => false
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
return Cache::remember(self::CACHE_KEY . $status->id, now()->addDays(7), function() use($status) {
|
|
|
|
return [
|
2021-01-30 02:46:55 +00:00
|
|
|
'covid' => Str::of(strtolower($status->caption))->contains(['covid','corona', 'coronavirus', 'vaccine', 'vaxx', 'vaccination', 'plandemic'])
|
2021-01-28 05:25:14 +00:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|