-
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
21 changed files
with
821 additions
and
80 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,8 @@ | ||
DB_DATABASE=testing | ||
DB_HOST=127.0.0.1 | ||
DB_CONNECTION=mysql | ||
DB_USERNAME=root | ||
DB_PASSWORD=password | ||
APP_KEY=base64:JzqP44/5fNz4B9cqzDtE6ktvlUmv9q9U0I2o4FjRtUY= | ||
APP_ENV=testing | ||
APP_DEBUG=true |
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,23 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\Badge\Badge; | ||
use App\Models\Badge\States\Printed; | ||
use Illuminate\Console\Command; | ||
|
||
class BadgesPrintCommand extends Command | ||
{ | ||
protected $signature = 'badges:print'; | ||
|
||
protected $description = 'Command description'; | ||
|
||
public function handle(): void | ||
{ | ||
// Prints all badges | ||
Badge::whereNull('printed_at')->update([ | ||
'status' => Printed::$name, | ||
'printed_at' => now(), | ||
]); | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\Badge\Badge; | ||
use App\Models\Badge\States\Pending; | ||
use Illuminate\Console\Command; | ||
|
||
class BadgesUnprintCommand extends Command | ||
{ | ||
protected $signature = 'badges:unprint'; | ||
|
||
protected $description = 'Command description'; | ||
|
||
public function handle(): void | ||
{ | ||
// Unprint all badges | ||
Badge::whereNotNull('printed_at')->update([ | ||
'status' => Pending::$name, | ||
'printed_at' => null, | ||
]); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
app/Console/Commands/CreateOrUpdateEventForStateCommand.php
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,72 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use App\Models\Event; | ||
use Carbon\Carbon; | ||
use App\Enum\EventStateEnum; | ||
|
||
class CreateOrUpdateEventForStateCommand extends Command | ||
{ | ||
protected $signature = 'event:state {state}'; | ||
|
||
protected $description = 'Creates or updates an event to match a specific state. Only for local or testing environments.'; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
public function handle() | ||
{ | ||
if (!app()->environment(['local', 'testing'])) { | ||
$this->error('This command can only be run in local or testing environments.'); | ||
return; | ||
} | ||
|
||
$state = $this->argument('state'); | ||
$event = Event::first(); | ||
|
||
$fromInput = EventStateEnum::tryFrom($state); | ||
|
||
switch ($fromInput) { | ||
case EventStateEnum::COUNTDOWN: | ||
$this->createOrUpdateEvent($event, now()->addDays(11), now()->addDays(20), now()->addDays(21), now()->addDays(30)); | ||
break; | ||
case EventStateEnum::PREORDER: | ||
$this->createOrUpdateEvent($event, now()->subDays(1), now()->subDays(10), now()->addDays(11), now()->addDays(20)); | ||
break; | ||
case EventStateEnum::LATE: | ||
$this->createOrUpdateEvent($event, now()->subDays(20), now()->subDays(10), now()->subDays(9), now()->addDays(10)); | ||
break; | ||
case EventStateEnum::CLOSED: | ||
$this->createOrUpdateEvent($event, now()->subDays(30), now()->subDays(20), now()->subDays(19), now()->subDays(1)); | ||
break; | ||
default: | ||
$this->error('Invalid state provided.'); | ||
return; | ||
} | ||
|
||
$this->info("Event has been created or updated to match the '$state' state."); | ||
} | ||
|
||
private function createOrUpdateEvent($event, $startsAt, $preorderStartsAt, $preorderEndsAt, $orderEndsAt) | ||
{ | ||
if ($event) { | ||
$event->update([ | ||
'starts_at' => $startsAt, | ||
'preorder_starts_at' => $preorderStartsAt, | ||
'preorder_ends_at' => $preorderEndsAt, | ||
'order_ends_at' => $orderEndsAt, | ||
]); | ||
} else { | ||
Event::create([ | ||
'starts_at' => $startsAt, | ||
'preorder_starts_at' => $preorderStartsAt, | ||
'preorder_ends_at' => $preorderEndsAt, | ||
'order_ends_at' => $orderEndsAt, | ||
]); | ||
} | ||
} | ||
} |
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,43 @@ | ||
<?php | ||
|
||
namespace Database\Factories\Badge; | ||
|
||
use App\Models\Badge\Badge; | ||
use App\Models\Badge\States\Pending; | ||
use App\Models\Badge\States\PickedUp; | ||
use App\Models\Badge\States\Printed; | ||
use App\Models\Badge\States\ReadyForPickup; | ||
use App\Models\Fursuit\Fursuit; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
use Illuminate\Support\Carbon; | ||
|
||
class BadgeFactory extends Factory | ||
{ | ||
protected $model = Badge::class; | ||
|
||
public function definition(): array | ||
{ | ||
return [ | ||
'is_free_badge' => $this->faker->boolean(), | ||
'extra_copy_of' => null, | ||
'status' => $this->faker->randomElement([ | ||
Pending::$name, | ||
Printed::$name, | ||
ReadyForPickup::$name, | ||
PickedUp::$name | ||
]), | ||
'dual_side_print' => $this->faker->boolean(), | ||
'extra_copy' => $this->faker->boolean(), | ||
'apply_late_fee' => $this->faker->boolean(), | ||
'subtotal' => $this->faker->randomNumber(), | ||
'tax_rate' => 19, | ||
'tax' => $this->faker->randomNumber(), | ||
'total' => $this->faker->randomNumber(), | ||
'printed_at' => Carbon::now(), | ||
'pickup_location' => $this->faker->word(), | ||
'ready_for_pickup_at' => Carbon::now(), | ||
'picked_up_at' => Carbon::now(), | ||
'fursuit_id' => Fursuit::factory(), | ||
]; | ||
} | ||
} |
Oops, something went wrong.