1. Go to this page and download the library: Download kossa/algerian-cities library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kossa / algerian-cities example snippets
// Retrieve all Wilayas
$wilayas = Wilaya::all();
// Retrieve all Communes
$communes = Commune::all();
// Get all Communes belonging to Algiers (Wilaya ID: 16)
$algiers_communes = Commune::where('wilaya_id', 16)->get();
$wilayas = wilayas(); // Get all Wilayas as $id => $name
$wilayas = wilayas('arabic_name'); // Get all Wilayas with names in Arabic
$communes = communes(); // Get all Communes as $id => $name
$communes = communes(16); // Get all Communes of Algiers (Wilaya ID: 16) as $id => $name
$communes = communes(16, $withWilaya = true); // Get all Communes of Algiers (16) including Wilayas: "Alger Centre, Alger"
$communes = communes(16, $withWilaya = true, $name = 'arabic_name'); // Get all Communes of Algiers (16) with Wilayas in Arabic: "الجزائر الوسطى, الجزائر"
$single_commune = commune(1); // Retrieve a single Commune model
$single_commune = commune(1, $withWilaya = true); // Retrieve a single Commune model, including its Wilaya
$single_wilaya = wilaya(1); // Retrieve a single Wilaya model
bash
php artisan algerian-cities:install
html
<!-- Select for Wilayas -->
<select>
@foreach (wilayas() as $id => $wilaya)
<option value="{{ $id }}">{{ $wilaya }}</option>
@endforeach
</select>
<!-- Select for Communes -->
<select>
@foreach (communes() as $id => $commune)
<option value="{{ $id }}">{{ $commune }}</option>
@endforeach
</select>
<!-- Select for Communes of Algiers (Wilaya ID: 16) -->
<select>
@foreach (communes(16) as $id => $commune)
<option value="{{ $id }}">{{ $commune }}</option>
@endforeach
</select>
<!-- Select for Communes with Wilaya Name (e.g., "Adrar, Adrar") -->
<select>
@foreach (communes(null, true) as $id => $commune)
<option value="{{ $id }}">{{ $commune }}</option>
@endforeach
</select>
<!-- Select for Communes with Wilaya Name in Arabic (e.g., "أدرار, أدرار") -->
<select>
@foreach (communes(null, true, 'arabic_name') as $id => $commune)
<option value="{{ $id }}">{{ $commune }}</option>
@endforeach
</select>
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.