first commit
This commit is contained in:
30
database/factories/ProjectFactory.php
Normal file
30
database/factories/ProjectFactory.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Priority;
|
||||
use App\Models\Project;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ProjectFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Project::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'company_id' => fake()->numberBetween(1, 10),
|
||||
'name' => fake()->sentence(3),
|
||||
'description' => fake()->paragraph,
|
||||
'important' => fake()->boolean,
|
||||
'source' => 'internal',
|
||||
'default_priority_id' => fn () => Priority::orderByRaw('RAND()')->first()->id,
|
||||
'created_at' => now()
|
||||
];
|
||||
}
|
||||
}
|
||||
23
database/factories/ProjectGroupFactory.php
Normal file
23
database/factories/ProjectGroupFactory.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\ProjectGroup>
|
||||
*/
|
||||
class ProjectGroupFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
40
database/factories/TaskFactory.php
Normal file
40
database/factories/TaskFactory.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\Role;
|
||||
use App\Models\Priority;
|
||||
use App\Models\Status;
|
||||
use App\Models\Task;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class TaskFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Task::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'task_name' => fake()->sentence(3),
|
||||
'description' => fake()->paragraph,
|
||||
'assigned_by' => fn() => User::where(['role_id' => Role::ADMIN])->first()->id,
|
||||
'important' => fake()->boolean,
|
||||
'priority_id' => Priority::inRandomOrder()->first()->id,
|
||||
'status_id' => Status::inRandomOrder()->first()->id,
|
||||
'start_date' => fake()->optional(0.8)->passthrough(Carbon::now()),
|
||||
'due_date' => fake()->optional(0.8)->passthrough(Carbon::now()->addDays(fake()->numberBetween(1, 40))),
|
||||
];
|
||||
}
|
||||
}
|
||||
32
database/factories/TimeIntervalFactory.php
Normal file
32
database/factories/TimeIntervalFactory.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Helpers\FakeScreenshotGenerator;
|
||||
use App\Models\TimeInterval;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class TimeIntervalFactory extends Factory
|
||||
{
|
||||
protected $model = TimeInterval::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'is_manual' => false,
|
||||
'start_at' => now()->subMinutes(5)->toDateTimeString(),
|
||||
'end_at' => now()->toDateTimeString(),
|
||||
'mouse_fill' => fake()->numberBetween(0, 100),
|
||||
'keyboard_fill' => fake()->numberBetween(0, 100),
|
||||
'activity_fill' => static fn(array $attributes) =>
|
||||
+$attributes['keyboard_fill'] + $attributes['mouse_fill'],
|
||||
];
|
||||
}
|
||||
|
||||
public function withScreenshot(): TimeIntervalFactory
|
||||
{
|
||||
return $this->afterCreating(function (TimeInterval $timeInterval) {
|
||||
FakeScreenshotGenerator::runForTimeInterval($timeInterval);
|
||||
});
|
||||
}
|
||||
}
|
||||
48
database/factories/UserFactory.php
Normal file
48
database/factories/UserFactory.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\Role;
|
||||
use App\Enums\ScreenshotsState;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'full_name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'url' => '',
|
||||
'company_id' => 1,
|
||||
'avatar' => '',
|
||||
'screenshots_state' => ScreenshotsState::REQUIRED,
|
||||
'manual_time' => 0,
|
||||
'computer_time_popup' => 300,
|
||||
'blur_screenshots' => 0,
|
||||
'web_and_app_monitoring' => 1,
|
||||
'screenshots_interval' => 5,
|
||||
'active' => 1,
|
||||
'password' => 'password',
|
||||
'user_language' => 'en',
|
||||
'role_id' => Role::USER,
|
||||
'type' => 'employee',
|
||||
'last_activity' => now()->subMinutes(random_int(1, 55)),
|
||||
];
|
||||
}
|
||||
|
||||
public function admin(): UserFactory
|
||||
{
|
||||
return $this->state(fn () => ['role_id' => Role::ADMIN]);
|
||||
}
|
||||
|
||||
public function manager(): UserFactory
|
||||
{
|
||||
return $this->state(fn () => ['role_id' => Role::MANAGER]);
|
||||
}
|
||||
|
||||
public function auditor(): UserFactory
|
||||
{
|
||||
return $this->state(fn () => ['role_id' => Role::AUDITOR]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user