mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
Migrations, Seeders, Models, Resources for User, Client, Project, Team, Mastertask, Subtask, Timeblock, Timesheet, Attachment
This commit is contained in:
1 parent
30ae7dab84
commit
8d88c0c4e6
35 files changed
+910
-14
No files matched your search
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Attachment>
|
||||
*/
|
||||
class AttachmentFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$extension = fake()->fileExtension();
|
||||
|
||||
return [
|
||||
'original_name' => fake()->words(2, true) . '.' . $extension,
|
||||
'disk_name' => Str::random(15) . '.' . $extension,
|
||||
'path' => fake()->imageUrl(),
|
||||
'extension' => $extension,
|
||||
'content_type' => fake()->mimeType(),
|
||||
'file_size' => fake()->numberBetween(1323,992385),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Client>
|
||||
*/
|
||||
class ClientFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$company = fake()->company();
|
||||
|
||||
return [
|
||||
'name' => $company,
|
||||
'code' => strtoupper(substr($company, 0, 5)),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\Project;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\MasterTask>
|
||||
*/
|
||||
class MasterTaskFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$project = Project::factory()->create();
|
||||
|
||||
return [
|
||||
'project_id' => $project->id,
|
||||
'title' => 'Master task ' . fake()->words(2, true),
|
||||
'estimated_time' => fake()->numberBetween(20,100),
|
||||
'tracked_time' => fake()->numberBetween(4,20),
|
||||
'deadline' => fake()->date(),
|
||||
'is_finished' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Client;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Project>
|
||||
*/
|
||||
class ProjectFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
|
||||
public function definition()
|
||||
{
|
||||
$name = fake()->country();
|
||||
|
||||
$client = Client::factory('App\Models\Client')->create();
|
||||
|
||||
return [
|
||||
'client_id' => $client->id,
|
||||
'name' => 'Project ' . $name,
|
||||
'code' => strtoupper(substr($name, 0, 3)) . '-2023-' . rand(1, 9),
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\MasterTask;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\SubTask>
|
||||
*/
|
||||
class SubTaskFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
// $user = User::factory()->create();
|
||||
// $mastertask = MasterTask::factory()->hasAttachments(random_int(0 , 3))->create();
|
||||
|
||||
return [
|
||||
'user_id' => 1,
|
||||
// 'master_task_id' => $mastertask->id,
|
||||
'estimated_time' => fake()->numberBetween(1,16),
|
||||
'tracked_time' => fake()->numberBetween(4,20),
|
||||
'is_finished' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ class TeamFactory extends Factory
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => fake()->company(),
|
||||
'name' => 'Team ' . fake()->colorName(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Timeblock>
|
||||
*/
|
||||
class TimeblockFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$start = fake()->dateTimeBetween('now', '+3 weeks');
|
||||
$end = Carbon::instance($start)->addHours(fake()->numberBetween(3, 5));
|
||||
|
||||
return [
|
||||
'start' => $start,
|
||||
'end' => fake()->dateTimeBetween($start, $end),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Timesheet>
|
||||
*/
|
||||
class TimesheetFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
return [
|
||||
'user_id' => $user->id,
|
||||
'time' => fake()->numberBetween(1,8),
|
||||
'synced_to_karat' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -17,15 +17,18 @@ class UserFactory extends Factory
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$firstname = fake()->firstname();
|
||||
$lastname = fake()->lastname();
|
||||
|
||||
return [
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email' => strtolower($firstname . '.' . $lastname . '@jandl.sk'),
|
||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
||||
'remember_token' => Str::random(10),
|
||||
'firstname' => fake()->firstname(),
|
||||
'lastname' => fake()->lastname(),
|
||||
'code' => strtoupper(Str::random(3)),
|
||||
'work_start' => '9.0',
|
||||
'work_end' => '17.0',
|
||||
'firstname' => $firstname,
|
||||
'lastname' => $lastname,
|
||||
'code' => strtoupper(substr($firstname, 0, 1) . substr($lastname, 0, 2)),
|
||||
'work_start' => rand(7, 10) . '.0',
|
||||
'work_end' => rand(15, 18) . '.0',
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user