country = request()->route('country');
}
public function with(): array
{
return [
'cities' => City::with(['country', 'createdBy'])
->when($this->search, fn($query)
=> $query->where('name', 'ilike', '%'.$this->search.'%'),
)
->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
@auth
{{ __('Edit') }}
@endauth
@endforeach