Files
fuel-price/app/Services/StationTaggingService.php
Ovidiu U c2c16c928b
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled
feat: add UserResource with is_admin toggle and delete
User management resource with editable is_admin field, postcode support,
admin filter, and inline delete action. Includes list and edit pages.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 18:31:55 +01:00

35 lines
934 B
PHP

<?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
{
$tradingName = strtolower($station->trading_name);
$brandName = strtolower($station->brand_name ?? '');
foreach (self::SUPERMARKET_BRANDS as $keyword => $normalisedBrand) {
if (str_contains($tradingName, $keyword) || str_contains($brandName, $keyword)) {
$station->is_supermarket = true;
$station->brand_name = $normalisedBrand;
return;
}
}
}
}