first change
This commit is contained in:
0
Modules/Employee/database/factories/.gitkeep
Normal file
0
Modules/Employee/database/factories/.gitkeep
Normal file
34
Modules/Employee/database/factories/DepartmentFactory.php
Normal file
34
Modules/Employee/database/factories/DepartmentFactory.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Employee\Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class DepartmentFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*/
|
||||
protected $model = \Modules\Employee\Models\Department::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
static $order = 1;
|
||||
$title = $this->faker->firstName();
|
||||
|
||||
return [
|
||||
'title' => $title,
|
||||
'slug' => Str::slug($title),
|
||||
'status' => $this->faker->randomElement([0, 1]),
|
||||
'order' => $order++,
|
||||
'user_id' => 1,
|
||||
'createdby' => 1,
|
||||
'updatedby' => 1,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
34
Modules/Employee/database/factories/DesignationFactory.php
Normal file
34
Modules/Employee/database/factories/DesignationFactory.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Employee\Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class DesignationFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*/
|
||||
protected $model = \Modules\Employee\Models\Designation::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
static $order = 1;
|
||||
$title = $this->faker->firstName();
|
||||
|
||||
return [
|
||||
'title' => $title,
|
||||
'slug' => Str::slug($title),
|
||||
'status' => $this->faker->randomElement([0, 1]),
|
||||
'order' => $order++,
|
||||
'department_id' => 1,
|
||||
'createdby' => 1,
|
||||
'updatedby' => 1,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
45
Modules/Employee/database/factories/EmployeeFactory.php
Normal file
45
Modules/Employee/database/factories/EmployeeFactory.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Employee\Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Modules\Employee\Models\Employee;
|
||||
|
||||
class EmployeeFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*/
|
||||
protected $model = Employee::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'first_name' => $this->faker->firstName,
|
||||
'middle_name' => $this->faker->firstName,
|
||||
'last_name' => $this->faker->lastName,
|
||||
'dob' => $this->faker->date(),
|
||||
'email' => $this->faker->unique()->safeEmail,
|
||||
'contact' => $this->faker->phoneNumber,
|
||||
'mobile' => $this->faker->phoneNumber,
|
||||
'photo' => $this->faker->imageUrl(),
|
||||
'guardian_name' => $this->faker->name,
|
||||
'guardian_contact' => $this->faker->phoneNumber,
|
||||
'temporary_address' => $this->faker->address,
|
||||
'permanent_address' => $this->faker->address,
|
||||
'employee_code' => $this->faker->unique()->numberBetween(1000, 9999),
|
||||
'join_date' => $this->faker->date(),
|
||||
'gender_id' => $this->faker->randomElement([1, 2]),
|
||||
'designation_id' => $this->faker->randomElement([1, 2, 3, 4]),
|
||||
'department_id' => $this->faker->randomElement([1, 2, 3]),
|
||||
'branch_id' => $this->faker->randomElement([1, 2, 3]),
|
||||
'user_id' => $this->faker->randomElement([1, 2, 3]),
|
||||
'status' => $this->faker->randomElement([1, 0]),
|
||||
'remarks' => $this->faker->sentence,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
0
Modules/Employee/database/migrations/.gitkeep
Normal file
0
Modules/Employee/database/migrations/.gitkeep
Normal file
@@ -0,0 +1,58 @@
|
||||
<?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('employees', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('first_name');
|
||||
$table->string('middle_name')->nullable();
|
||||
$table->string('last_name');
|
||||
|
||||
$table->date('dob')->nullable();
|
||||
$table->string('email')->nullable();
|
||||
$table->string('contact', 20)->nullable();
|
||||
$table->string('mobile', 20)->nullable();
|
||||
$table->string('photo')->nullable();
|
||||
|
||||
$table->string('guardian_name')->nullable();
|
||||
$table->string('guardian_contact')->nullable();
|
||||
|
||||
$table->text('temporary_address')->nullable();
|
||||
$table->text('permanent_address')->nullable();
|
||||
|
||||
$table->string('employee_code')->unique();
|
||||
$table->date('join_date')->nullable();
|
||||
|
||||
$table->unsignedBigInteger('gender_id')->nullable();
|
||||
$table->unsignedBigInteger('designation_id')->nullable();
|
||||
$table->unsignedBigInteger('department_id')->nullable();
|
||||
|
||||
$table->unsignedBigInteger('branch_id')->nullable();
|
||||
$table->unsignedBigInteger('user_id')->nullable();
|
||||
|
||||
$table->string('status')->default("active");
|
||||
$table->unsignedBigInteger('createdby')->unsigned()->nullable();
|
||||
$table->unsignedBigInteger('updatedby')->unsigned()->nullable();
|
||||
$table->text('remarks')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('employees');
|
||||
}
|
||||
};
|
@@ -0,0 +1,36 @@
|
||||
<?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('departments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title')->nullable();
|
||||
$table->string('slug')->nullable();
|
||||
|
||||
$table->integer('status')->default(1);
|
||||
$table->integer('order')->unsigned()->nullable();
|
||||
|
||||
$table->unsignedBigInteger('user_id')->unsigned()->nullable();
|
||||
$table->unsignedBigInteger('createdby')->unsigned()->nullable();
|
||||
$table->unsignedBigInteger('updatedby')->unsigned()->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('departments');
|
||||
}
|
||||
};
|
@@ -0,0 +1,36 @@
|
||||
<?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('designations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title')->nullable();
|
||||
$table->string('slug')->nullable();
|
||||
|
||||
$table->integer('status')->default(1);
|
||||
$table->integer('order')->unsigned()->nullable();
|
||||
|
||||
$table->unsignedBigInteger('department_id')->unsigned()->nullable();
|
||||
$table->unsignedBigInteger('createdby')->unsigned()->nullable();
|
||||
$table->unsignedBigInteger('updatedby')->unsigned()->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('designations');
|
||||
}
|
||||
};
|
0
Modules/Employee/database/seeders/.gitkeep
Normal file
0
Modules/Employee/database/seeders/.gitkeep
Normal file
22
Modules/Employee/database/seeders/EmployeeDatabaseSeeder.php
Normal file
22
Modules/Employee/database/seeders/EmployeeDatabaseSeeder.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Employee\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Modules\Employee\Models\Department;
|
||||
use Modules\Employee\Models\Designation;
|
||||
use Modules\Employee\Models\Employee;
|
||||
|
||||
class EmployeeDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
Employee::factory(50)->create();
|
||||
Department::factory(5)->create();
|
||||
Designation::factory(5)->create();
|
||||
// $this->call([]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user