feat: add StationTaggingService with supermarket detection

This commit is contained in:
Ovidiu U
2026-04-03 18:49:34 +01:00
parent 7f153fb08d
commit 80a8a9f93b
3 changed files with 107 additions and 7 deletions

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Services;
use App\Models\Station;
class StationTaggingService
{
/** @var array<string, string> brand keyword → normalised brand name */
private const SUPERMARKET_BRANDS = [
'tesco' => 'Tesco',
'asda' => 'Asda',
'morrisons' => 'Morrisons',
'sainsbury' => 'Sainsbury\'s',
'aldi' => 'Aldi',
'lidl' => 'Lidl',
'costco' => 'Costco',
];
public function tag(Station $station): void
{
$name = strtolower($station->trading_name);
foreach (self::SUPERMARKET_BRANDS as $keyword => $normalisedBrand) {
if (str_contains($name, $keyword)) {
$station->is_supermarket = true;
$station->brand_name = $normalisedBrand;
return;
}
}
}
}