Skip to content

Commit

Permalink
Merge pull request #542 from DnD-Montreal/hotfix-session-seats-backpack
Browse files Browse the repository at this point in the history
Hotfix: add session seats to backpack
  • Loading branch information
m-triassi authored Apr 3, 2022
2 parents ff2bb0d + 27af773 commit f078a82
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
3 changes: 3 additions & 0 deletions app/Http/Controllers/Admin/SessionCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ protected function setupListOperation()
CRUD::column('adventure_id');
CRUD::column('dungeonMaster');
CRUD::column('table');
CRUD::column('seats');
CRUD::column('start_time');
CRUD::column('end_time');
}
Expand Down Expand Up @@ -109,6 +110,8 @@ protected function setupCreateOperation()
CRUD::field('adventure_id');
CRUD::field('dungeonMaster');
CRUD::field('table');
CRUD::field('seats')->default(8);
CRUD::field('language')->type('enum');
CRUD::field('start_time');
CRUD::field('end_time');
}
Expand Down
31 changes: 29 additions & 2 deletions database/factories/CharacterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,38 @@ class CharacterFactory extends Factory
*/
public function definition()
{
$races = [
"Dwarf",
"Elf",
"Halfling",
"Human",
"Dragonborn",
"Gnome",
"Half-Elf",
"Half-Orc",
"Tiefling",
];

$classes = [
"Barbarian",
"Bard",
"Cleric",
"Druid",
"Fighter",
"Monk",
"Paladin",
"Ranger",
"Rogue",
"Sorcerer",
"Warlock",
"Wizard",
];

return [
'user_id' => User::factory(),
'name' => $this->faker->name(),
'race' => $this->faker->word(),
'class' => $this->faker->word(),
'race' => $this->faker->randomElement($races),
'class' => $this->faker->randomElement($classes),
'level' => $this->faker->numberBetween(1, 20),
'faction' => $this->faker->randomElement(array_values(Character::FACTIONS)),
'downtime' => $this->faker->numberBetween(0, 1000),
Expand Down
2 changes: 1 addition & 1 deletion database/factories/EntryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function definition()
'event_id' => Event::factory(),
'dungeon_master_id' => User::factory(),
'dungeon_master' => $this->faker->word(),
'date_played' => $this->faker->dateTime(),
'date_played' => $this->faker->dateTimeBetween("-5 years"),
'location' => $this->faker->word(),
'type' => $this->faker->word(),
'length' => $this->faker->numberBetween(0, 10),
Expand Down
4 changes: 2 additions & 2 deletions database/factories/SessionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SessionFactory extends Factory
*/
public function definition()
{
$startTime = $this->faker->dateTime();
$startTime = $this->faker->dateTimeBetween("-5 Years");

return [
'event_id' => Event::factory(),
Expand All @@ -35,7 +35,7 @@ public function definition()
'table' => $this->faker->randomDigit()+1,
'seats' => $this->faker->numberBetween(2, 8),
'start_time' => $startTime,
'end_time' => $this->faker->dateTimeBetween($startTime, $endDate = 'now'),
'end_time' => $this->faker->dateTimeBetween($startTime),
'language' => $this->faker->randomElement(["FR","EN"]),
];
}
Expand Down
3 changes: 2 additions & 1 deletion database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,12 @@ private function generateSessions(Collection $events, Collection $dm)
// Each event will have 3 sessions being run at them
foreach ($events as $event) {
$seats = rand(2, 7);
$dm = $dm->shuffle();
$sessions = Session::factory(3)
->has(Character::factory($seats - rand(0, 2)))
->sequence(fn ($sequence) => ['dungeon_master_id' => $dm[$sequence->index]])
->create([
'event_id' => $event->id,
'dungeon_master_id' => $dm->random()->id,
'seats' => $seats
])->merge($sessions);
}
Expand Down

0 comments on commit f078a82

Please sign in to comment.