Add branch & province model

This commit is contained in:
2023-11-23 15:34:04 +05:00
parent 0309e8f7d8
commit fe68420bab
11 changed files with 490 additions and 5 deletions

View File

@@ -0,0 +1,30 @@
<?php
use App\Repos\System\Settings\Location\RegionRepo;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('provinces', function (Blueprint $table) {
$table->id();
$table->string('region', 2)->index();
$table->jsonb('name');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('provinces');
}
};

View File

@@ -0,0 +1,37 @@
<?php
use App\Repos\System\Settings\Location\RegionRepo;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('branches', function (Blueprint $table) {
$table->id();
$table->jsonb('name');
$table->jsonb('address')->nullable();
$table->string('unique_code')->index()->nullable();
$table->string('region', 2)->index();
$table->foreignId('province_id')->constrained()->nullOnDelete();
$table->string('billing_username')->nullable();
$table->string('billing_password')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('branches');
}
};

View File

@@ -3,7 +3,9 @@
namespace Database\Seeders;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use App\Models\User;
use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Role;
class DatabaseSeeder extends Seeder
{
@@ -12,11 +14,50 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
// \App\Models\User::factory(10)->create();
$this->createRoles();
$this->createAdmins();
}
// \App\Models\User::factory()->create([
// 'name' => 'Test User',
// 'email' => 'test@example.com',
// ]);
public function createRoles(): void
{
if (Role::count() > 0) {
return;
}
$roles = [
'king',
'superadmin',
'admin',
'operator',
'user',
];
foreach ($roles as $role) {
Role::create(['name' => $role]);
}
}
public function createAdmins(): void
{
$admins = [
[
'name' => 'Nurmuhammet Allanov',
'email' => 'nurmuhammet@mail.com',
'password' => '$2y$10$O7LFNdFIT3Rmfeo8tUfbqekB0x0incovkRP6eQuzvb7dVXysQyyBC',
], [
'name' => 'Mahmyt Allaberdiyev',
'email' => 'mahmyt1206@gmail.com',
'password' => '$2y$10$O7LFNdFIT3Rmfeo8tUfbqekB0x0incovkRP6eQuzvb7dVXysQyyBC',
], [
'name' => 'Döwran Myratlyýew',
'email' => 'dovran.m@mail.ru',
'password' => '$2y$10$EFQaBb.aM2KJRGGtuhjdM.3m4Mtm/vw68NjU2280d2RICDGI.o336',
],
];
foreach ($admins as $admin) {
$user = User::create($admin);
$user->assignRole('superadmin');
}
}
}