first commit

This commit is contained in:
Sampanna Rimal
2024-08-27 17:48:06 +05:45
commit 53c0140f58
10839 changed files with 1125847 additions and 0 deletions

1
database/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.sqlite*

View File

@ -0,0 +1,40 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*
* @return $this
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}

View File

@ -0,0 +1,32 @@
<?php
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('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
}
};

View File

@ -0,0 +1,28 @@
<?php
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('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('password_reset_tokens');
}
};

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
};

View File

@ -0,0 +1,32 @@
<?php
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('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('failed_jobs');
}
};

View File

@ -0,0 +1,33 @@
<?php
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('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->string('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};

View File

@ -0,0 +1,138 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$teams = config('permission.teams');
$tableNames = config('permission.table_names');
$columnNames = config('permission.column_names');
$pivotRole = $columnNames['role_pivot_key'] ?? 'role_id';
$pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id';
if (empty($tableNames)) {
throw new \Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
}
if ($teams && empty($columnNames['team_foreign_key'] ?? null)) {
throw new \Exception('Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
}
Schema::create($tableNames['permissions'], function (Blueprint $table) {
$table->bigIncrements('id'); // permission id
$table->string('name'); // For MySQL 8.0 use string('name', 125);
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
$table->timestamps();
$table->unique(['name', 'guard_name']);
});
Schema::create($tableNames['roles'], function (Blueprint $table) use ($teams, $columnNames) {
$table->bigIncrements('id'); // role id
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
}
$table->string('name'); // For MySQL 8.0 use string('name', 125);
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
$table->timestamps();
if ($teams || config('permission.testing')) {
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
} else {
$table->unique(['name', 'guard_name']);
}
});
Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
$table->unsignedBigInteger($pivotPermission);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
$table->foreign($pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->onDelete('cascade');
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
} else {
$table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
}
});
Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
$table->unsignedBigInteger($pivotRole);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
$table->foreign($pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->onDelete('cascade');
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
} else {
$table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
}
});
Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
$table->unsignedBigInteger($pivotPermission);
$table->unsignedBigInteger($pivotRole);
$table->foreign($pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->onDelete('cascade');
$table->foreign($pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->onDelete('cascade');
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
});
app('cache')
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
->forget(config('permission.cache.key'));
}
/**
* Reverse the migrations.
*/
public function down(): void
{
$tableNames = config('permission.table_names');
if (empty($tableNames)) {
throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
}
Schema::drop($tableNames['role_has_permissions']);
Schema::drop($tableNames['model_has_roles']);
Schema::drop($tableNames['model_has_permissions']);
Schema::drop($tableNames['roles']);
Schema::drop($tableNames['permissions']);
}
};

View File

@ -0,0 +1,34 @@
<?php
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('tbl_documents', function (Blueprint $table) {
$table->unsignedTinyInteger('document_id')->autoIncrement();
$table->string('document_name')->nullable();
$table->text('document_path')->nullable();
$table->text('document_for_ref')->nullable();
$table->unsignedBigInteger('documentable_id');
$table->string('documentable_type');
$table->integer('status')->default(11);
$table->mediumText('description');
$table->mediumText('remarks');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tbl_documents');
}
};

View File

@ -0,0 +1,31 @@
<?php
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('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('notifications');
}
};

View File

@ -0,0 +1,22 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Modules\Admin\Models\Country;
class CountrySeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$countries = [
['name' => 'Nepal', 'code' => 'NP'],
];
Country::insert($countries);
}
}

View File

@ -0,0 +1,42 @@
<?php
namespace Database\Seeders;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Hash;
use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Role;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*/
public function run(): void
{
$this->callOnce([
CountrySeeder::class,
ProvinceSeeder::class,
DistrictSeeder::class,
MunicipalitySeeder::class,
DepartmentSeeder::class,
DesignationSeeder::class,
DropdownSeeder::class,
]);
$admin = \App\Models\User::factory()->create([
'name' => 'Admin User',
'email' => 'admin@gmail.com',
'employee_id' => 1,
'password' => Hash::make('password'),
]);
$adminRole = Role::create(['name' => 'admin']);
$memberRole = Role::create(['name' => 'hr']);
$memberRole = Role::create(['name' => 'employee']);
$admin->assignRole($adminRole);
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Modules\Admin\Models\Department;
class DepartmentSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$departments = [
['name' => 'Marketing'],
['name' => 'Finance'],
['name' => 'HR'],
['name' => 'IT'],
];
Department::insert($departments);
}
}

View File

@ -0,0 +1,62 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Modules\Admin\Models\Department;
use Modules\Admin\Models\Designation;
class DesignationSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$designations = [
[
'name' => "Manager",
'department_name' => 'HR'
],
[
'name' => "Analyst",
'department_name' => 'Marketing'
],
[
'name' => "HR Specialist",
'department_name' => 'HR'
],
[
'name' => "Sales Representative",
'department_name' => "Marketing"
],
[
'name' => "Full Stack",
'department_name' => "IT"
],
[
'name' => "Backend",
'department_name' => "IT"
],
];
foreach ($designations as $designation) {
$department = Department::where('name', $designation['department_name'])->first();
if ($department) {
$designationData = [
'department_id' => $department->department_id,
'name' => $designation['name']
];
}
Designation::create($designationData);
}
}
}

View File

@ -0,0 +1,357 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Modules\Admin\Models\District;
class DistrictSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$province_1 = [
[
'province_id' => 1,
'name' => 'Bhojpur',
],
[
'province_id' => 1,
'name' => 'Dhankuta',
],
[
'province_id' => 1,
'name' => 'Ilam',
],
[
'province_id' => 1,
'name' => 'Jhapa',
],
[
'province_id' => 1,
'name' => 'Khotang',
],
[
'province_id' => 1,
'name' => 'Morang',
],
[
'province_id' => 1,
'name' => 'Okhaldhunga',
],
[
'province_id' => 1,
'name' => 'Panchthar',
],
[
'province_id' => 1,
'name' => 'Sankhuwasabha',
],
[
'province_id' => 1,
'name' => 'Solukhumbu',
],
[
'province_id' => 1,
'name' => 'Sunsari',
],
[
'province_id' => 1,
'name' => 'Taplejung',
],
[
'province_id' => 1,
'name' => 'Terhathum',
],
[
'province_id' => 1,
'name' => 'Udayapur',
],
];
$province_2 = [
[
'province_id' => 2,
'name' => 'Parsa',
],
[
'province_id' => 2,
'name' => 'Bara',
],
[
'province_id' => 2,
'name' => 'Rautahat',
],
[
'province_id' => 2,
'name' => 'Sarlahi',
],
[
'province_id' => 2,
'name' => 'Dhanusha',
],
[
'province_id' => 2,
'name' => 'Siraha',
],
[
'province_id' => 2,
'name' => 'Mahottari',
],
[
'province_id' => 2,
'name' => 'Saptari',
],
];
$province_3 = [
[
'province_id' => 3,
'name' => 'Sindhuli',
],
[
'province_id' => 3,
'name' => 'Ramechhap',
],
[
'province_id' => 3,
'name' => 'Dolakha',
],
[
'province_id' => 3,
'name' => 'Bhaktapur',
],
[
'province_id' => 3,
'name' => 'Dhading',
],
[
'province_id' => 3,
'name' => 'Kathmandu',
],
[
'province_id' => 3,
'name' => 'Kavrepalanchok',
],
[
'province_id' => 3,
'name' => 'Lalitpur',
],
[
'province_id' => 3,
'name' => 'Nuwakot',
],
[
'province_id' => 3,
'name' => 'Rasuwa',
],
[
'province_id' => 3,
'name' => 'Sindhupalchok',
],
[
'province_id' => 3,
'name' => 'Chitwan',
],
[
'province_id' => 3,
'name' => 'Makawanpur',
],
];
$province_4 = [
[
'province_id' => 4,
'name' => 'Baglung',
],
[
'province_id' => 4,
'name' => 'Gorkha',
],
[
'province_id' => 4,
'name' => 'Kaski',
],
[
'province_id' => 4,
'name' => 'Lamjung',
],
[
'province_id' => 4,
'name' => 'Manang',
],
[
'province_id' => 4,
'name' => 'Mustang',
],
[
'province_id' => 4,
'name' => 'Myagdi',
],
[
'province_id' => 4,
'name' => 'Nawalpur',
],
[
'province_id' => 4,
'name' => 'Parbat',
],
[
'province_id' => 4,
'name' => 'Syangja',
],
[
'province_id' => 4,
'name' => 'Tanahu',
],
];
$province_5 = [
[
'province_id' => 5,
'name' => 'Kapilvastu',
],
[
'province_id' => 5,
'name' => 'Parasi',
],
[
'province_id' => 5,
'name' => 'Rupandehi',
],
[
'province_id' => 5,
'name' => 'Arghakhanchi',
],
[
'province_id' => 5,
'name' => 'Gulmi',
],
[
'province_id' => 5,
'name' => 'Palpa',
],
[
'province_id' => 5,
'name' => 'Dang',
],
[
'province_id' => 5,
'name' => 'Pyuthan',
],
[
'province_id' => 5,
'name' => 'Rolpa',
],
[
'province_id' => 5,
'name' => 'Eastern Rukum',
],
[
'province_id' => 5,
'name' => 'Banke',
],
[
'province_id' => 5,
'name' => 'Bardiya',
],
];
$province_6 = [
[
'province_id' => 6,
'name' => 'Western Rukum',
],
[
'province_id' => 6,
'name' => 'Salyan',
],
[
'province_id' => 6,
'name' => 'Dolpa',
],
[
'province_id' => 6,
'name' => 'Humla',
],
[
'province_id' => 6,
'name' => 'Jumla',
],
[
'province_id' => 6,
'name' => 'Kalikot',
],
[
'province_id' => 6,
'name' => 'Mugu',
],
[
'province_id' => 6,
'name' => 'Surkhet',
],
[
'province_id' => 6,
'name' => 'Dailekh',
],
[
'province_id' => 6,
'name' => 'Jajarkot',
],
];
$province_7 = [
[
'province_id' => 7,
'name' => 'Kailali',
],
[
'province_id' => 7,
'name' => 'Achham',
],
[
'province_id' => 7,
'name' => 'Doti',
],
[
'province_id' => 7,
'name' => 'Bajhang',
],
[
'province_id' => 7,
'name' => 'Bajura',
],
[
'province_id' => 7,
'name' => 'Kanchanpur',
],
[
'province_id' => 7,
'name' => 'Dadeldhura',
],
[
'province_id' => 7,
'name' => 'Baitadi',
],
[
'province_id' => 7,
'name' => 'Darchula',
],
];
$districts = array_merge(
$province_1,
$province_2,
$province_3,
$province_4,
$province_5,
$province_6,
$province_7,
);
District::insert($districts);
}
}

View File

@ -0,0 +1,39 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Modules\Admin\Models\Dropdown;
use Modules\Admin\Models\Field;
class DropdownSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$inputArr = [
'Gender' => ['Male', 'Female', 'Others'],
'Nationality' => ['Nepali', 'Others'],
'Ethnicity' => ['Brahmin', 'Chettri', 'Janajati', 'Others'],
'Ranking Type' => ['Promotion', 'Demotion'],
];
foreach ($inputArr as $key => $value) {
$fieldModel = Field::updateOrCreate(['title' => $key], [
'title' => $key,
]);
if ($fieldModel) {
foreach ($value as $k => $v) {
Dropdown::updateOrCreate(['title' => $v,
'fid' => $fieldModel->id], [
'title' => $v,
'fid' => $fieldModel->id,
]);
}
}
}
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Modules\Admin\Models\Gender;
class GenderSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$genders = [
['name' => 'Male'],
['name' => 'Female'],
];
Gender::insert($genders);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,21 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Modules\Admin\Models\Nationality;
class NationalitySeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$nationalities = [
['name' => 'Nepalese'],
['name' => 'Other'],
];
Nationality::insert($nationalities);
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Permission;
class PermissionSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$permission = Permission::create(['name' => 'create leaves']);
$permission = Permission::create(['name' => 'access leaves']);
$permission = Permission::create(['name' => 'edit leaves']);
$permission = Permission::create(['name' => 'delete leaves']);
$permission = Permission::create(['name' => 'access roles']);
$permission = Permission::create(['name' => 'edit roles']);
$permission = Permission::create(['name' => 'create roles']);
$permission = Permission::create(['name' => 'delete roles']);
$permission = Permission::create(['name' => 'access users']);
$permission = Permission::create(['name' => 'edit users']);
$permission = Permission::create(['name' => 'create users']);
$permission = Permission::create(['name' => 'delete users']);
$permission = Permission::create(['name' => 'access permissions']);
$permission = Permission::create(['name' => 'edit permissions']);
$permission = Permission::create(['name' => 'create permissions']);
$permission = Permission::create(['name' => 'delete permissions']);
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Modules\Admin\Models\Province;
class ProvinceSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$provinces = [
['name' => 'Koshi', 'country_id' => 1],
['name' => 'Madesh', 'country_id' => 1],
['name' => 'Bagmati', 'country_id' => 1],
['name' => 'Gandaki', 'country_id' => 1],
['name' => 'Lumbini', 'country_id' => 1],
['name' => 'Karnali', 'country_id' => 1],
['name' => 'Sudurpaschim', 'country_id' => 1],
];
Province::insert($provinces);
}
}