Menu

## CityForm extends Component
in package
uses LivewireAlert

CityForm.php : 27

Class CityForm

Livewire component responsible for creating and updating city records in the Admin Settings section.

This component handles:

- City creation
- City editing
- Country & state selection
- Form validation
- Success alerts

### Table of Contents

#### Properties

$cityEditId : int|string|null
  City ID used for edit mode.
$country : int|string|null
  Selected country ID.
$name : string|null
  City name.
$state : int|string|null
  Selected state ID.
$statelist : Collection|array<string|int, mixed>|null
  List of states filtered by selected country.
$status : int|string
  City status (active/inactive).

#### Methods

changeState() : void
  Update the state list based on selected country.
mount() : void
  Lifecycle hook executed when the component is mounted.
render() : View
  Render the Livewire component view.
submitCity() : RedirectResponse
  Handle city form submission.

### Properties

#### $cityEditId

CityForm.php : 68

City ID used for edit mode.

`public int|string|null $cityEditId`

#### $country

CityForm.php : 36

Selected country ID.

`public int|string|null $country`

##### Attributes

#[Rule]
  'required'

#### $name

CityForm.php : 52

City name.

`public string|null $name`

##### Attributes

#[Rule]
  'required'

#### $state

CityForm.php : 44

Selected state ID.

`public int|string|null $state`

##### Attributes

#[Rule]
  'required'

#### $statelist

CityForm.php : 75

List of states filtered by selected country.

`public Collection|array<string|int, mixed>|null $statelist`

#### $status

CityForm.php : 60

City status (active/inactive).

`public int|string $status = 1`

##### Attributes

#[Rule]
  'required'

### Methods

#### changeState()

CityForm.php : 108

Update the state list based on selected country.

`public changeState() : void`

#### mount()

CityForm.php : 86

Lifecycle hook executed when the component is mounted.

`public mount(int|string|null $id) : void`

Loads city details for edit mode and initializes state list if country is available.

##### Parameters

$id : int|string|null

  City ID

#### render()

CityForm.php : 155

Render the Livewire component view.

`public render() : View`

Loads country list and state list for the city form.

##### Return values

View

#### submitCity()

CityForm.php : 125

Handle city form submission.

`public submitCity() : RedirectResponse`

Validates input data and performs:

- City creation (if new)
- City update (if editing)

Displays success alerts and redirects back to the cities listing page.

##### Return values

RedirectResponse

## Search results