All checks were successful
linter / quality (pull_request) Successful in 1m21s
security / Dependency Audit (pull_request) Successful in 1m25s
security / Static Analysis (pull_request) Successful in 1m49s
tests / ci (8.4) (pull_request) Successful in 1m23s
tests / ci (8.5) (pull_request) Successful in 1m27s
- Add towns table with town_pid, town_name, state, population, town_class, date_retired - Add AustralianState enum with label and abbreviation helpers - Add Town model with active() and search() scopes - Add SyncTowns job that paginates ArcGIS API and upserts all 1977 towns - Schedule SyncTowns to run nightly at 02:00 - Add /towns/search endpoint returning JSON suggestions filtered by name and state - Add Alpine-powered autocomplete on origin/destination fields in create form - Add state filter dropdown in journeys card header to narrow autocomplete results
42 lines
884 B
PHP
42 lines
884 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\AustralianState;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Town extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\TownFactory> */
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'town_pid',
|
|
'town_name',
|
|
'state',
|
|
'population',
|
|
'town_class',
|
|
'date_retired',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'state' => AustralianState::class,
|
|
'date_retired' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function scopeActive(Builder $query): void
|
|
{
|
|
$query->whereNull('date_retired');
|
|
}
|
|
|
|
public function scopeSearch(Builder $query, string $term): void
|
|
{
|
|
$query->where('town_name', 'like', $term.'%');
|
|
}
|
|
}
|