-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
166 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace App\Enums; | ||
|
||
enum ChallengeType: string | ||
{ | ||
case PERSONAL = 'personal'; | ||
case TEAM = 'team'; | ||
|
||
public static function values(): array | ||
{ | ||
return array_map(fn (self $case) => $case->value, self::cases()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
return [ | ||
'achievements' => [ | ||
[ | ||
'name' => 'Достижение 1', | ||
'description' => 'Достижение 2', | ||
'image_id' => null | ||
], | ||
[ | ||
'name' => 'Достижение 1', | ||
'description' => 'Достижение 2', | ||
'image_id' => null | ||
], | ||
[ | ||
'name' => 'Достижение 1', | ||
'description' => 'Достижение 2', | ||
'image_id' => null | ||
], | ||
], | ||
|
||
'challenges' => [ | ||
[ | ||
'name' => 'Задание 1', | ||
'description' => 'Задание 2', | ||
'image_id' => null | ||
], | ||
[ | ||
'name' => 'Задание 1', | ||
'description' => 'Задание 2', | ||
'image_id' => null | ||
], | ||
[ | ||
'name' => 'Задание 1', | ||
'description' => 'Задание 2', | ||
'image_id' => null | ||
], | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Database\Factories; | ||
|
||
use App\Enums\ChallengeType; | ||
use App\Models\Achievement; | ||
use Carbon\Carbon; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
class ChallengeFactory extends Factory | ||
{ | ||
public function definition(): array | ||
{ | ||
$now = Carbon::now(); | ||
|
||
return [ | ||
'name' => fake()->text(20), | ||
'description' => fake()->text(), | ||
'start_date' => $now, | ||
'end_date' => $now->addDays(fake()->numberBetween(1, 30)), | ||
'achievement_id' => Achievement::query()->inRandomOrder()->first(), | ||
'image_id' => null, | ||
'type' => fake()->randomElement([ | ||
ChallengeType::PERSONAL, | ||
ChallengeType::TEAM | ||
]) | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Database\Seeders; | ||
|
||
use App\Models\Achievement; | ||
use Illuminate\Database\Seeder; | ||
|
||
class AchievementsSeeder extends Seeder | ||
{ | ||
public function run(): void | ||
{ | ||
$achievements = config('base.achievements'); | ||
|
||
foreach ($achievements as $achievement) { | ||
Achievement::query()->create($achievement); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Database\Seeders; | ||
|
||
use App\Models\Challenge; | ||
use Illuminate\Database\Seeder; | ||
|
||
class ChallengesSeeder extends Seeder | ||
{ | ||
public function run(): void | ||
{ | ||
$challenges = config('base.challenges'); | ||
|
||
foreach ($challenges as $challenge) { | ||
Challenge::factory()->create($challenge); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Database\Seeders; | ||
|
||
use App\Models\User; | ||
use Illuminate\Database\Seeder; | ||
|
||
class UsersSeeder extends Seeder | ||
{ | ||
public function run(): void | ||
{ | ||
User::factory(10)->create(); | ||
|
||
User::factory()->create([ | ||
'name' => 'Admin', | ||
'email' => '[email protected]', | ||
'is_admin' => true, | ||
]); | ||
} | ||
} |