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
namespace App;
use Illuminate\Database\Eloquent\Model;
use Kossa\AlgerianCities\Commune;
use Kossa\AlgerianCities\Wilaya;
class AnyClass extends Model
{
$wilayas = Wilaya::all(); // Get all wilayas
$communes = Commune::all(); // Get all communes
$algiers_communes = Commune::where('wilaya_id', 16)->get(); // get all communes of Algiers(16)
}
$wilayas = wilayas(); // get all wilayas as $id => $name
$wilayas = wilayas('arabic_name'); // get all wilayas in arabic
$communes = communes(); // get all communes as $id => $name
$communes = communes(16); // get all communes of Algiers(16) as $id => $name
$communes = communes(16, $withWilaya = true); // get all communes of Algiers(16) with name of wilayas like : Alger Centre, Alger
$communes = communes(16, $withWilaya = true, $name = "arabic_name"); // get all communes of Algiers(16) with name of wilayas in arabic like : الجزائر الوسطى, الجزائر
$single_commune = commune(1); // get a single commune model
$single_commune = commune(1, $withWilaya = true); // get a single commune model
// wilayas
<select>
@foreach (wilayas() as $id => $wilaya)
<option value="{{ $id }}">{{ $wilaya }}</option>
@endforeach
</select>
// communes
<select>
@foreach (communes() as $id => $commune)
<option value="{{ $id }}">{{ $commune }}</option>
@endforeach
</select>
// communes of Algiers(16)
<select>
@foreach (communes($wilaya_id = 16) as $id => $commune)
<option value="{{ $id }}">{{ $commune }}</option>
@endforeach
</select>
// communes with wilaya name : Adrar, Adrar ...
<select>
@foreach (communes($wilaya_id = null, $withWilaya = true) as $id => $commune)
<option value="{{ $id }}">{{ $commune }}</option>
@endforeach
</select>
// communes with wilaya name in arabic : أدرار, أدرار ...
<select>
@foreach (communes($wilaya_id = null, $withWilaya = 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.