-
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.
Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # app/Models/User.php
- Loading branch information
Showing
18 changed files
with
320 additions
and
50 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 was deleted.
Oops, something went wrong.
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,35 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\BelongsToMany; | ||
|
||
class Team extends Model | ||
{ | ||
use HasFactory; | ||
|
||
public $timestamps = true; | ||
|
||
protected $fillable = [ | ||
'name', | ||
'description', | ||
'code' | ||
]; | ||
|
||
public function users(): belongsToMany | ||
{ | ||
return $this->belongsToMany(User::class, 'users_teams'); | ||
} | ||
|
||
public function challenges(): belongsToMany | ||
{ | ||
return $this->belongsToMany(Challenge::class, 'teams_challenges'); | ||
} | ||
|
||
public function achievements(): belongsToMany | ||
{ | ||
return $this->belongsToMany(Achievement::class, 'teams_achievements'); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Database\Factories; | ||
|
||
use App\Models\Team; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
/** | ||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Team> | ||
*/ | ||
class TeamFactory extends Factory | ||
{ | ||
/** | ||
* Define the model's default state. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
protected $model = Team::class; | ||
|
||
public function definition(): array | ||
{ | ||
return [ | ||
'name' => $this->faker->company, | ||
'description' => $this->faker->sentence, | ||
'code' => strtoupper($this->faker->unique()->lexify('??###')), | ||
]; | ||
} | ||
} |
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.