StatusLabelService.php 706 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Services;
  3. use Illuminate\Support\Facades\Cache;
  4. use App\Status;
  5. use Illuminate\Support\Str;
  6. class StatusLabelService
  7. {
  8. const CACHE_KEY = 'pf:services:status_label:_v0:';
  9. public static function get(Status $status)
  10. {
  11. if(config('instance.label.covid.enabled') == false || !$status) {
  12. return [
  13. 'covid' => false
  14. ];
  15. }
  16. return Cache::remember(self::CACHE_KEY . $status->id, now()->addDays(7), function() use($status) {
  17. if(!$status->caption) {
  18. return [
  19. 'covid' => false
  20. ];
  21. }
  22. return [
  23. 'covid' => Str::of(strtolower($status->caption))->contains(['covid','corona', 'coronavirus', 'vaccine', 'vaxx', 'vaccination', 'plandemic'])
  24. ];
  25. });
  26. }
  27. }