* wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * lint fixes * missing empty lines * translations * fix vue version * #134 - fixes * fix * fix * #134 - fix * fix * fix * #134 - added tests * #134 - fix to translations * #134 - tests * #134 - fix * Update database/factories/ResumeFactory.php Co-authored-by: Krzysztof Rewak <krzysztof.rewak@gmail.com> * #134 - fix * #134 - fix Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl> Co-authored-by: Krzysztof Rewak <krzysztof.rewak@gmail.com>
This commit is contained in:
92
database/factories/ResumeFactory.php
Normal file
92
database/factories/ResumeFactory.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Toby\Eloquent\Models\Resume;
|
||||
use Toby\Eloquent\Models\Technology;
|
||||
|
||||
class ResumeFactory extends Factory
|
||||
{
|
||||
protected $model = Resume::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
"name" => fn(array $attributes): ?string => empty($attributes["user_id"]) ? $this->faker->name : null,
|
||||
"education" => $this->generateEducation(),
|
||||
"languages" => $this->generateLanguages(),
|
||||
"technologies" => $this->generateTechnologies(),
|
||||
"projects" => $this->generateProjects(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function generateEducation(): array
|
||||
{
|
||||
$items = [];
|
||||
|
||||
for ($i = 0; $i < $this->faker->numberBetween(1, 2); $i++) {
|
||||
$items[] = [
|
||||
"school" => $this->faker->sentence,
|
||||
"degree" => $this->faker->sentence,
|
||||
"fieldOfStudy" => $this->faker->sentence,
|
||||
"current" => false,
|
||||
"startDate" => Carbon::create($this->faker->date)->format("m/Y"),
|
||||
"endDate" => Carbon::create($this->faker->date)->format("m/Y"),
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
protected function generateLanguages(): array
|
||||
{
|
||||
$languages = new Collection(["English", "Polish", "German"]);
|
||||
$number = $this->faker->numberBetween(1, $languages->count());
|
||||
|
||||
return $languages->random($number)
|
||||
->map(fn(string $language): array => [
|
||||
"name" => $language,
|
||||
"level" => $this->faker->numberBetween(1, 6),
|
||||
])
|
||||
->all();
|
||||
}
|
||||
|
||||
protected function generateTechnologies(): array
|
||||
{
|
||||
$technologies = Technology::all()->pluck("name");
|
||||
$number = $this->faker->numberBetween(2, $technologies->count());
|
||||
|
||||
return $technologies->random($number)
|
||||
->map(fn(string $technology): array => [
|
||||
"name" => $technology,
|
||||
"level" => $this->faker->numberBetween(1, 5),
|
||||
])
|
||||
->all();
|
||||
}
|
||||
|
||||
protected function generateProjects(): array
|
||||
{
|
||||
$items = [];
|
||||
$technologies = Technology::all()->pluck("name");
|
||||
|
||||
for ($i = 0; $i < $this->faker->numberBetween(1, 3); $i++) {
|
||||
$number = $this->faker->numberBetween(2, $technologies->count());
|
||||
|
||||
$items[] = [
|
||||
"description" => $this->faker->text,
|
||||
"technologies" => $technologies->random($number)->all(),
|
||||
"current" => false,
|
||||
"startDate" => Carbon::create($this->faker->date)->format("m/Y"),
|
||||
"endDate" => Carbon::create($this->faker->date)->format("m/Y"),
|
||||
"tasks" => $this->faker->text,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
}
|
20
database/factories/TechnologyFactory.php
Normal file
20
database/factories/TechnologyFactory.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Toby\Eloquent\Models\Technology;
|
||||
|
||||
class TechnologyFactory extends Factory
|
||||
{
|
||||
protected $model = Technology::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
"name" => $this->faker->unique()->word,
|
||||
];
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Toby\Eloquent\Models\User;
|
||||
|
||||
return new class() extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create("resumes", function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignIdFor(User::class)->nullable()->constrained()->cascadeOnDelete();
|
||||
$table->string("name")->nullable();
|
||||
$table->json("education");
|
||||
$table->json("languages");
|
||||
$table->json("technologies");
|
||||
$table->json("projects");
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists("resumes");
|
||||
}
|
||||
};
|
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class() extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create("technologies", function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->string("name")->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists("technologies");
|
||||
}
|
||||
};
|
@@ -20,6 +20,8 @@ use Toby\Domain\States\VacationRequest\WaitingForAdministrative;
|
||||
use Toby\Domain\States\VacationRequest\WaitingForTechnical;
|
||||
use Toby\Domain\WorkDaysCalculator;
|
||||
use Toby\Eloquent\Models\Key;
|
||||
use Toby\Eloquent\Models\Resume;
|
||||
use Toby\Eloquent\Models\Technology;
|
||||
use Toby\Eloquent\Models\User;
|
||||
use Toby\Eloquent\Models\VacationLimit;
|
||||
use Toby\Eloquent\Models\VacationRequest;
|
||||
@@ -332,5 +334,35 @@ class DemoSeeder extends Seeder
|
||||
->for($user)
|
||||
->create();
|
||||
}
|
||||
|
||||
Technology::factory()->createMany([
|
||||
["name" => "Laravel"],
|
||||
["name" => "Symfony"],
|
||||
["name" => "CakePHP"],
|
||||
["name" => "PHP"],
|
||||
["name" => "Livewire"],
|
||||
["name" => "Inertia"],
|
||||
["name" => "Vue"],
|
||||
["name" => "Javascript"],
|
||||
["name" => "Redis"],
|
||||
["name" => "AWS"],
|
||||
["name" => "Tailwind"],
|
||||
["name" => "CSS"],
|
||||
["name" => "PHPUnit"],
|
||||
["name" => "Cypress"],
|
||||
["name" => "Behat"],
|
||||
["name" => "Pest"],
|
||||
["name" => "Golang"],
|
||||
]);
|
||||
|
||||
foreach ($users as $user) {
|
||||
Resume::factory()
|
||||
->for($user)
|
||||
->create();
|
||||
}
|
||||
|
||||
Resume::factory()
|
||||
->count(3)
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user