Files
ntspi-app/database/factories/DepartmentFactory.php
T
F4ilji c01016a154 Migrate backend to Porto architecture and fix minor bugs
- Fully transitioned the backend to the Porto architectural pattern
- Improved code organization and maintainability
- Fixed minor bugs and inconsistencies
2025-05-12 08:47:43 +05:00

43 lines
1.2 KiB
PHP

<?php
namespace Database\Factories;
use App\Containers\InstituteStructure\Models\Faculty;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Department>
*/
class DepartmentFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$title = $this->faker->sentence;
$slug = Str::slug($title);
$content = array_map(function () {
return [
'type' => $this->faker->randomElement(['heading', 'paragraph']),
'data' => [
'id' => $this->faker->numberBetween(1, 1000000),
'content' => $this->faker->paragraph,
],
];
}, range(1, $this->faker->numberBetween(1, 5)));
$faculty_id = Faculty::inRandomOrder()->first();
return [
'title' => $title,
'slug' => $slug,
'content' => $content,
'faculty_id' => $faculty_id,
'created_at' => now(),
'updated_at' => now(),
];
}
}