country = request()->route('country', config('app.domain_country')); } public function with(): array { return [ 'cities' => City::query() ->with(['country', 'createdBy']) ->when($this->search, fn($query) => $query->where('name', 'ilike', '%'.$this->search.'%'), ) ->whereHas('country', fn($query) => $query->where('countries.code', $this->country)) ->orderBy('name') ->paginate(15), ]; } }; ?>
{{ __('Cities') }}
@auth {{ __('Create City') }} @endauth
{{ __('Name') }} {{ __('Country') }} {{ __('Population') }} {{ __('Created By') }} {{ __('Actions') }} @foreach ($cities as $city) {{ $city->name }} @if($city->country) {{ $city->country->name }} @endif @if($city->population) {{ number_format($city->population) }} @if($city->population_date) ({{ $city->population_date }}) @endif @endif @if($city->createdBy) {{ Str::limit($city->createdBy->name, 30) }} @endif
@if(auth()->check()) {{ __('Edit') }} @elseif(!auth()->check()) {{ __('Log in') }} @endif
@endforeach