create cmms machine service with tests
This commit is contained in:
30
database/factories/CMMSMachineFactory.php
Normal file
30
database/factories/CMMSMachineFactory.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\CMMSMachine>
|
||||
*/
|
||||
class CMMSMachineFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'car_name' => $this->faker->name,
|
||||
'car_group' => $this->faker->name,
|
||||
'car_id' => $this->faker->numberBetween(1, 10),
|
||||
'car_status' => $this->faker->lexify,
|
||||
'machine_code' => $this->faker->numerify,
|
||||
'unit_name' => $this->faker->name,
|
||||
'unit_group' => $this->faker->name,
|
||||
'plak_number' => $this->faker->numerify,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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('cmms_machines', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('car_name')->nullable();
|
||||
$table->string('car_group')->nullable();
|
||||
$table->unsignedBigInteger('car_id')->nullable();
|
||||
$table->string('car_status')->nullable();
|
||||
$table->string('machine_code')->nullable();
|
||||
$table->string('unit_name')->nullable();
|
||||
$table->string('unit_group')->nullable();
|
||||
$table->string('plak_number')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cmms_machines');
|
||||
}
|
||||
};
|
||||
18
database/seeders/CMMSMachineSeeder.php
Normal file
18
database/seeders/CMMSMachineSeeder.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\CMMSMachine;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class CMMSMachineSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
CMMSMachine::factory(5)->create();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user