generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from elaborate-code/migrating-and-seeding
Migrating and seeding
- Loading branch information
Showing
6 changed files
with
128 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('wilayas', function (Blueprint $table) { | ||
$table->id(); | ||
|
||
$table->string('name'); | ||
|
||
$table->unique('name'); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::dropIfExists('wilayas'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
namespace ElaborateCode\AlgerianStates\Database\Seeders; | ||
|
||
use Illuminate\Database\Console\Seeds\WithoutModelEvents; | ||
use Illuminate\Database\Seeder; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class WilayaSeeder extends Seeder | ||
{ | ||
use WithoutModelEvents; | ||
|
||
public function run(): void | ||
{ | ||
$wilayas = | ||
[ | ||
['id' => '1', 'name' => 'Adrar'], | ||
['id' => '2', 'name' => 'Chlef'], | ||
['id' => '3', 'name' => 'Laghouat'], | ||
['id' => '4', 'name' => 'Oum El Bouaghi'], | ||
['id' => '5', 'name' => 'Batna'], | ||
['id' => '6', 'name' => 'B茅ja茂a'], | ||
['id' => '7', 'name' => 'Biskra'], | ||
['id' => '8', 'name' => 'B茅char'], | ||
['id' => '9', 'name' => 'Blida'], | ||
['id' => '10', 'name' => 'Bouira'], | ||
['id' => '11', 'name' => 'Tamanrasset'], | ||
['id' => '12', 'name' => 'T茅bessa'], | ||
['id' => '13', 'name' => 'Tlemcen'], | ||
['id' => '14', 'name' => 'Tiaret'], | ||
['id' => '15', 'name' => 'Tizi Ouzou'], | ||
['id' => '16', 'name' => 'Alger'], | ||
['id' => '17', 'name' => 'Djelfa'], | ||
['id' => '18', 'name' => 'Jijel'], | ||
['id' => '19', 'name' => 'S茅tif'], | ||
['id' => '20', 'name' => 'Sa茂da'], | ||
['id' => '21', 'name' => 'Skikda'], | ||
['id' => '22', 'name' => 'Sidi Bel Abb猫s'], | ||
['id' => '23', 'name' => 'Annaba'], | ||
['id' => '24', 'name' => 'Guelma'], | ||
['id' => '25', 'name' => 'Constantine'], | ||
['id' => '26', 'name' => 'M茅d茅a'], | ||
['id' => '27', 'name' => 'Mostaganem'], | ||
['id' => '28', 'name' => "M'Sila"], | ||
['id' => '29', 'name' => 'Mascara'], | ||
['id' => '30', 'name' => 'Ouargla'], | ||
['id' => '31', 'name' => 'Oran'], | ||
['id' => '32', 'name' => 'El Bayadh'], | ||
['id' => '33', 'name' => 'Illizi'], | ||
['id' => '34', 'name' => 'Bordj Bou Arreridj'], | ||
['id' => '35', 'name' => 'Boumerd猫s'], | ||
['id' => '36', 'name' => 'El Tarf'], | ||
['id' => '37', 'name' => 'Tindouf'], | ||
['id' => '38', 'name' => 'Tissemsilt'], | ||
['id' => '39', 'name' => 'El Oued'], | ||
['id' => '40', 'name' => 'Khenchela'], | ||
['id' => '41', 'name' => 'Souk Ahras'], | ||
['id' => '42', 'name' => 'Tipaza'], | ||
['id' => '43', 'name' => 'Mila'], | ||
['id' => '44', 'name' => 'A茂n Defla'], | ||
['id' => '45', 'name' => 'Na芒ma'], | ||
['id' => '46', 'name' => 'A茂n T茅mouchent'], | ||
['id' => '47', 'name' => 'Gharda茂a'], | ||
['id' => '48', 'name' => 'Relizane'], | ||
['id' => '49', 'name' => "El M'Ghair"], | ||
['id' => '50', 'name' => 'El Meniaa'], | ||
['id' => '51', 'name' => 'Ouled Djellal'], | ||
['id' => '52', 'name' => 'Bordj Badji Mokhtar'], | ||
['id' => '53', 'name' => 'B茅ni Abb猫s'], | ||
['id' => '54', 'name' => 'Timimoun'], | ||
['id' => '55', 'name' => 'Touggourt'], | ||
['id' => '56', 'name' => 'Djanet'], | ||
['id' => '57', 'name' => 'In Salah'], | ||
['id' => '58', 'name' => 'In Guezzam'], | ||
]; | ||
|
||
DB::table('wilayas')->insert($wilayas); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace ElaborateCode\AlgerianStates\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Wilaya extends Model | ||
{ | ||
protected $fillable = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
use ElaborateCode\AlgerianStates\Models\Wilaya; | ||
|
||
it('has 58 records', function () { | ||
// dump(Wilaya::all()->toArray()); | ||
$this->assertDatabaseCount('wilayas', 58); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters