
* wip * wip * wip * wip * fix * wip * wip * fix * fix * cs fix * #116 - fix * #116 - changed home-office icon * Apply suggestions from code review Co-authored-by: Krzysztof Rewak <krzysztof.rewak@gmail.com> * #116 - cr fix * #116 - cs fix * #116 - cs fix * Apply suggestions from code review Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * #5 - bump codestyle Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl> Co-authored-by: Krzysztof Rewak <krzysztof.rewak@gmail.com> Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>
46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Toby\Infrastructure\Slack\Handlers;
|
|
|
|
use Illuminate\Support\Carbon;
|
|
use Spatie\SlashCommand\Request;
|
|
use Spatie\SlashCommand\Response;
|
|
use Toby\Domain\Actions\VacationRequest\CreateAction;
|
|
use Toby\Domain\Enums\VacationType;
|
|
use Toby\Eloquent\Models\User;
|
|
use Toby\Eloquent\Models\YearPeriod;
|
|
use Toby\Infrastructure\Slack\Traits\FindsUserBySlackId;
|
|
|
|
class HomeOffice extends SignatureHandler
|
|
{
|
|
use FindsUserBySlackId;
|
|
|
|
protected $signature = "toby zdalnie";
|
|
protected $description = "Pracuj dzisiaj zdalnie";
|
|
|
|
public function handle(Request $request): Response
|
|
{
|
|
$user = $this->findUserBySlackId($request->userId);
|
|
|
|
$this->createRemoteday($user, Carbon::today());
|
|
|
|
return $this->respondToSlack(":white_check_mark: Pracujesz dzisiaj zdalnie");
|
|
}
|
|
|
|
protected function createRemoteday(User $user, Carbon $date): void
|
|
{
|
|
$yearPeriod = YearPeriod::findByYear($date->year);
|
|
|
|
app(CreateAction::class)->execute([
|
|
"user_id" => $user->id,
|
|
"type" => VacationType::HomeOffice,
|
|
"from" => $date,
|
|
"to" => $date,
|
|
"year_period_id" => $yearPeriod->id,
|
|
"flow_skipped" => false,
|
|
], $user);
|
|
}
|
|
}
|