#116 - integration with slack #129
@@ -4,11 +4,22 @@ declare(strict_types=1);
|
||||
|
||||
namespace Toby\Architecture\Providers;
|
||||
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Notifications\ChannelManager;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Toby\Domain\Slack\Channels\SlackApiChannel;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register()
|
||||
{
|
||||
Notification::resolved(function (ChannelManager $service) {
|
||||
$service->extend("slack", fn(Application $app) => $app->make(SlackApiChannel::class));
|
||||
});
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
Carbon::macro("toDisplayString", fn() => $this->translatedFormat("d.m.Y"));
|
||||
|
||||
@@ -53,7 +53,6 @@ class CreateAction
|
||||
$vacationRequest->save();
|
||||
|
||||
$days = $this->vacationDaysCalculator->calculateDays(
|
||||
$vacationRequest->yearPeriod,
|
||||
$vacationRequest->from,
|
||||
$vacationRequest->to,
|
||||
);
|
||||
|
||||
@@ -20,7 +20,17 @@ class VacationRequestCreatedNotification extends Notification
|
||||
|
||||
public function via(): array
|
||||
{
|
||||
return ["mail"];
|
||||
return ["mail", "slack"];
|
||||
}
|
||||
|
||||
public function toSlack(): string
|
||||
{
|
||||
$url = route("vacation.requests.show", ["vacationRequest" => $this->vacationRequest->id]);
|
||||
|
||||
return implode("\n", [
|
||||
$this->buildDescription(),
|
||||
"<${url}|Zobacz szczegóły>",
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,18 +90,16 @@ class VacationRequestCreatedNotification extends Notification
|
||||
protected function buildDescription(): string
|
||||
{
|
||||
$name = $this->vacationRequest->name;
|
||||
$appName = config("app.name");
|
||||
|
||||
if ($this->vacationRequest->creator()->is($this->vacationRequest->user)) {
|
||||
return __("The vacation request :title has been created correctly in the :appName.", [
|
||||
return __("The vacation request :title for user :user has been created successfully.", [
|
||||
"user" => $this->vacationRequest->user->profile->full_name,
|
||||
"title" => $name,
|
||||
"appName" => $appName,
|
||||
]);
|
||||
}
|
||||
|
||||
return __("The vacation request :title has been created correctly by user :creator on your behalf in the :appName.", [
|
||||
return __("The vacation request :title has been created successfully by user :creator on your behalf.", [
|
||||
"title" => $this->vacationRequest->name,
|
||||
"appName" => $appName,
|
||||
"creator" => $this->vacationRequest->creator->profile->full_name,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,17 @@ class VacationRequestStatusChangedNotification extends Notification
|
||||
|
||||
public function via(): array
|
||||
{
|
||||
return ["mail"];
|
||||
return ["mail", "slack"];
|
||||
}
|
||||
|
||||
public function toSlack(): string
|
||||
{
|
||||
$url = route("vacation.requests.show", ["vacationRequest" => $this->vacationRequest->id]);
|
||||
|
||||
return implode("\n", [
|
||||
$this->buildDescription(),
|
||||
"<${url}|Zobacz szczegóły>",
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,27 +53,17 @@ class VacationRequestStatusChangedNotification extends Notification
|
||||
protected function buildMailMessage(string $url): MailMessage
|
||||
{
|
||||
$user = $this->user->profile->first_name;
|
||||
$title = $this->vacationRequest->name;
|
||||
$type = $this->vacationRequest->type->label();
|
||||
$status = $this->vacationRequest->state->label();
|
||||
$from = $this->vacationRequest->from->toDisplayString();
|
||||
$to = $this->vacationRequest->to->toDisplayString();
|
||||
$days = $this->vacationRequest->vacations()->count();
|
||||
$requester = $this->vacationRequest->user->profile->full_name;
|
||||
|
||||
return (new MailMessage())
|
||||
->greeting(__("Hi :user!", [
|
||||
"user" => $user,
|
||||
]))
|
||||
->subject(__("Vacation request :title has been :status", [
|
||||
"title" => $title,
|
||||
"status" => $status,
|
||||
]))
|
||||
->line(__("The vacation request :title from user :requester has been :status.", [
|
||||
"title" => $title,
|
||||
"requester" => $requester,
|
||||
"status" => $status,
|
||||
]))
|
||||
->subject($this->buildSubject())
|
||||
->line($this->buildDescription())
|
||||
->line(__("Vacation type: :type", [
|
||||
"type" => $type,
|
||||
]))
|
||||
@@ -74,4 +74,21 @@ class VacationRequestStatusChangedNotification extends Notification
|
||||
]))
|
||||
->action(__("Click here for details"), $url);
|
||||
}
|
||||
|
||||
protected function buildSubject(): string
|
||||
{
|
||||
return __("Vacation request :title has been :status", [
|
||||
"title" => $this->vacationRequest->name,
|
||||
"status" => $this->vacationRequest->state->label(),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function buildDescription(): string
|
||||
{
|
||||
return __("The vacation request :title from user :requester has been :status.", [
|
||||
"title" => $this->vacationRequest->name,
|
||||
"requester" => $this->vacationRequest->user->profile->full_name,
|
||||
"status" => $this->vacationRequest->state->label(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,17 @@ class VacationRequestWaitsForApprovalNotification extends Notification
|
||||
|
||||
public function via(): array
|
||||
{
|
||||
return ["mail"];
|
||||
return ["mail", "slack"];
|
||||
}
|
||||
|
||||
public function toSlack(): string
|
||||
{
|
||||
$url = route("vacation.requests.show", ["vacationRequest" => $this->vacationRequest->id]);
|
||||
|
||||
return implode("\n", [
|
||||
$this->buildDescription(),
|
||||
"<${url}|Zobacz szczegóły>",
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
25
app/Domain/Slack/Channels/SlackApiChannel.php
Normal file
@@ -0,0 +1,25 @@
|
||||
|
|
||||
<?php
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
declare(strict_types=1);
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
namespace Toby\Domain\Slack\Channels;
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
use Illuminate\Http\Client\Response;
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
class SlackApiChannel
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
{
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
public function send($notifiable, Notification $notification): Response
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
{
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
$baseUrl = config("services.slack.url");
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
$url = "{$baseUrl}/chat.postMessage";
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
$channel = $notifiable->routeNotificationFor('slack', $notification);
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
return Http::withToken(config("services.slack.client_token"))
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
->post($url, [
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
"channel" => $channel,
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
"text" => $notification->toSlack(),
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
]);
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
}
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
}
|
||||
|
Can you type Can you type `$notifiable`?
Hm, I don't if I wouldn't put his to Infrastucture directory. Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think. Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait In general, it can be anything that uses trait `Notifiable`
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
51
app/Domain/Slack/Handlers/CatchAll.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack\Handlers;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Spatie\SlashCommand\Attachment;
|
||||
use Spatie\SlashCommand\AttachmentField;
|
||||
use Spatie\SlashCommand\Handlers\CatchAll as BaseCatchAllHandler;
|
||||
use Spatie\SlashCommand\Handlers\SignatureHandler;
|
||||
use Spatie\SlashCommand\Request;
|
||||
use Spatie\SlashCommand\Response;
|
||||
|
||||
class CatchAll extends BaseCatchAllHandler
|
||||
{
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$response = $this->respondToSlack("Nie rozpoznaję tej komendy: `/{$request->command} {$request->text}`");
|
||||
|
||||
[$command] = explode(' ', $this->request->text ?? "");
|
||||
|
||||
$alternativeHandlers = $this->findAlternativeHandlers($command);
|
||||
|
||||
if ($alternativeHandlers->count()) {
|
||||
$response->withAttachment($this->getCommandListAttachment($alternativeHandlers));
|
||||
}
|
||||
|
||||
if ($this->containsHelpHandler($alternativeHandlers)) {
|
||||
$response->withAttachment(Attachment::create()
|
||||
->setText("Aby wyświetlić wszystkie komendy, napisz: `/toby pomoc`")
|
||||
);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function getCommandListAttachment(Collection $handlers): Attachment
|
||||
{
|
||||
$attachmentFields = $handlers
|
||||
->map(function (SignatureHandler $handler) {
|
||||
return AttachmentField::create($handler->getFullCommand(), $handler->getDescription());
|
||||
})
|
||||
->all();
|
||||
|
||||
return Attachment::create()
|
||||
->setColor('warning')
|
||||
->setTitle('Czy miałeś na myśli:')
|
||||
->setFields($attachmentFields);
|
||||
}
|
||||
}
|
||||
74
app/Domain/Slack/Handlers/DailySummary.php
Normal file
@@ -0,0 +1,74 @@
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
<?php
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
declare(strict_types=1);
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
namespace Toby\Domain\Slack\Handlers;
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
use Illuminate\Support\Carbon;
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
use Illuminate\Support\Collection;
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
use Spatie\SlashCommand\Attachment;
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
use Spatie\SlashCommand\Request;
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
use Spatie\SlashCommand\Response;
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
use Spatie\SlashCommand\Handlers\SignatureHandler;
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
use Toby\Domain\Enums\VacationType;
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
use Toby\Domain\VacationTypeConfigRetriever;
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
use Toby\Eloquent\Models\User;
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
use Toby\Eloquent\Models\Vacation;
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
class DailySummary extends SignatureHandler
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
{
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
protected $signature = "toby dzisiaj";
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
protected $description = "Podsumowanie";
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
public function handle(Request $request): Response
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
{
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
$configRetriever = app(VacationTypeConfigRetriever::class);
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
$now = Carbon::today();
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
/** @var Collection $absences */
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
$absences = Vacation::query()
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->with(["user", "vacationRequest"])
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->whereDate("date", $now)
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->approved()
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->whereTypes(VacationType::all()->filter(fn(VacationType $type) => $configRetriever->isVacation($type)))
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->get()
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->map(fn(Vacation $vacation) => $vacation->user->profile->full_name);
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
/** @var Collection $remoteDays */
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
$remoteDays = Vacation::query()
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->with(["user", "vacationRequest"])
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->whereDate("date", $now)
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->approved()
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->whereTypes(VacationType::all()->filter(fn(VacationType $type) => !$configRetriever->isVacation($type)))
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->get()
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->map(fn(Vacation $vacation) => $vacation->user->profile->full_name);
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
$birthdays = User::query()
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->whereRelation("profile", "birthday", $now)
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->get()
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->map(fn(User $user) => $user->profile->full_name);
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
$absencesAttachment = Attachment::create()
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->setTitle("Nieobecności :palm_tree:")
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->setColor('#eab308')
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->setText($absences->isNotEmpty() ? $absences->implode("\n") : "Wszyscy dzisiaj pracują :muscle:");
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
$remoteAttachment = Attachment::create()
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->setTitle("Praca zdalna :house_with_garden:")
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->setColor('#d946ef')
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->setText($remoteDays->isNotEmpty() ? $remoteDays->implode("\n") : "Wszyscy dzisiaj są w biurze :boom:");
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
$birthdayAttachment = Attachment::create()
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->setTitle("Urodziny :birthday:")
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->setColor('#3C5F97')
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->setText($birthdays->isNotEmpty() ? $birthdays->implode("\n") : "Dzisiaj nikt nie ma urodzin :cry:");
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
return $this->respondToSlack("Podsumowanie dla dnia {$now->toDisplayString()}")
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->withAttachment($absencesAttachment)
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->withAttachment($remoteAttachment)
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->withAttachment($birthdayAttachment)
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
->displayResponseToEveryoneOnChannel();
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
}
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
}
|
||||
```suggestion
$absences = $dailySummaryRetriever->getAbsences($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$remoteDays = $dailySummaryRetriever->getRemoteDays($now)
->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name);
$birthdays = $dailySummaryRetriever->getBirthdays($now)
->map(fn(User $user): string => $user->profile->full_name);
```
What if we would have five more activities? Maybe this could be encapsulated somehow? What if we would have five more activities? Maybe this could be encapsulated somehow?
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack;
|
||||
namespace Toby\Domain\Slack\Handlers;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Spatie\SlashCommand\Request;
|
||||
@@ -13,13 +13,13 @@ use Toby\Eloquent\Models\User;
|
||||
|
||||
class GiveKeysTo extends SignatureHandler
|
||||
{
|
||||
protected $signature = "toby klucze:dla {to}";
|
||||
protected $signature = "toby klucze:dla {użytkownik}";
|
||||
|
||||
protected $description = "Daj klucze użytkownikowi {to}";
|
||||
protected $description = "Daj klucze wskazanemu użytkownikowi";
|
||||
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$to = $this->getArgument('to');
|
||||
$to = $this->getArgument('użytkownik');
|
||||
|
||||
$id = Str::between($to, "@", "|");
|
||||
|
||||
45
app/Domain/Slack/Handlers/Help.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack\Handlers;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Spatie\SlashCommand\Attachment;
|
||||
use Spatie\SlashCommand\AttachmentField;
|
||||
use Spatie\SlashCommand\Handlers\Help as BaseHelpHandler;
|
||||
use Spatie\SlashCommand\Handlers\SignatureHandler;
|
||||
use Spatie\SlashCommand\Request;
|
||||
use Spatie\SlashCommand\Response;
|
||||
|
||||
class Help extends BaseHelpHandler
|
||||
{
|
||||
protected $signature = "toby pomoc";
|
||||
protected $description = "Wyświetl wszystkie dostępne komendy tobiego";
|
||||
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$handlers = $this->findAvailableHandlers();
|
||||
|
||||
return $this->displayListOfAllCommands($handlers);
|
||||
}
|
||||
|
||||
protected function displayListOfAllCommands(Collection $handlers): Response
|
||||
{
|
||||
$attachmentFields = $handlers
|
||||
->sort(function (SignatureHandler $handlerA, SignatureHandler $handlerB) {
|
||||
return strcmp($handlerA->getFullCommand(), $handlerB->getFullCommand());
|
||||
})
|
||||
->map(function (SignatureHandler $handler) {
|
||||
return AttachmentField::create("/{$handler->getSignature()}", $handler->getDescription());
|
||||
})
|
||||
->all();
|
||||
|
||||
return $this->respondToSlack('Dostępne komendy')
|
||||
->withAttachment(
|
||||
Attachment::create()
|
||||
->setColor('good')
|
||||
->setFields($attachmentFields)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack;
|
||||
namespace Toby\Domain\Slack\Handlers;
|
||||
|
||||
use Illuminate\Support\Carbon;
|
||||
use Spatie\SlashCommand\Request;
|
||||
@@ -15,12 +15,12 @@ use Toby\Eloquent\Models\YearPeriod;
|
||||
|
||||
class HomeOffice extends SignatureHandler
|
||||
{
|
||||
protected $signature = "toby zdalnie {date=dzisiaj}";
|
||||
protected $description = "Praca zdalna {kiedy}";
|
||||
protected $signature = "toby zdalnie {kiedy?}";
|
||||
protected $description = "Pracuj zdalnie wybranego dnia (domyślnie dzisiaj)";
|
||||
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$date = $this->getDateFromArgument($this->getArgument('date'));
|
||||
$date = $this->getDateFromArgument($this->getArgument('kiedy') ?? "dzisiaj");
|
||||
$user = $this->findUserBySlackId($request->userId);
|
||||
|
||||
$yearPeriod = YearPeriod::findByYear($date->year);
|
||||
@@ -34,7 +34,8 @@ class HomeOffice extends SignatureHandler
|
||||
"flow_skipped" => false,
|
||||
], $user);
|
||||
|
||||
return $this->respondToSlack("Praca zdalna dnia {$date->toDisplayString()} została utworzona pomyślnie");
|
||||
return $this->respondToSlack("Praca zdalna dnia {$date->toDisplayString()} została utworzona pomyślnie.")
|
||||
->displayResponseToEveryoneOnChannel();
|
||||
}
|
||||
|
||||
protected function getDateFromArgument(string $argument): Carbon
|
||||
33
app/Domain/Slack/Handlers/KeyList.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack\Handlers;
|
||||
|
||||
use Spatie\SlashCommand\Attachment;
|
||||
use Spatie\SlashCommand\Request;
|
||||
use Spatie\SlashCommand\Response;
|
||||
use Spatie\SlashCommand\Handlers\SignatureHandler;
|
||||
use Toby\Eloquent\Models\Key;
|
||||
|
||||
class KeyList extends SignatureHandler
|
||||
{
|
||||
protected $signature = "toby klucze";
|
||||
|
||||
protected $description = "Lista wszystkich kluczy";
|
||||
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$keys = Key::query()
|
||||
->orderBy("id")
|
||||
->get()
|
||||
->map(fn(Key $key) => "Klucz nr {$key->id} - <@{$key->user->profile->slack_id}>");
|
||||
|
||||
return $this->respondToSlack("Lista kluczy")
|
||||
->withAttachment(
|
||||
Attachment::create()
|
||||
->setColor('#3C5F97')
|
||||
->setText($keys->implode("\n"))
|
||||
);
|
||||
}
|
||||
}
|
||||
24
app/Domain/Slack/Handlers/SaySomething.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack\Handlers;
|
||||
|
||||
use Spatie\SlashCommand\Request;
|
||||
use Spatie\SlashCommand\Response;
|
||||
use Spatie\SlashCommand\Handlers\SignatureHandler;
|
||||
|
||||
class SaySomething extends SignatureHandler
|
||||
{
|
||||
protected $signature = "toby powiedz {zdanie}";
|
||||
|
||||
protected $description = "Powiedz zdanie";
|
||||
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$sentence = $this->getArgument("zdanie");
|
||||
|
||||
return $this->respondToSlack($sentence)
|
||||
->displayResponseToEveryoneOnChannel();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack;
|
||||
namespace Toby\Domain\Slack\Handlers;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Spatie\SlashCommand\Request;
|
||||
@@ -13,13 +13,13 @@ use Toby\Eloquent\Models\User;
|
||||
|
||||
class TakeKeysFrom extends SignatureHandler
|
||||
{
|
||||
protected $signature = "toby klucze:od {from}";
|
||||
protected $signature = "toby klucze:od {użytkownik}";
|
||||
|
||||
protected $description = "Zabierz klucze użytkownikowi {from}";
|
||||
protected $description = "Zabierz klucze wskazanemu użytkownikowi";
|
||||
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$from = $this->getArgument('from');
|
||||
$from = $this->getArgument("użytkownik");
|
||||
|
||||
$id = Str::between($from, "@", "|");
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack;
|
||||
|
||||
use Spatie\SlashCommand\Request;
|
||||
use Spatie\SlashCommand\Response;
|
||||
use Spatie\SlashCommand\Handlers\SignatureHandler;
|
||||
use Toby\Eloquent\Models\Key;
|
||||
|
||||
class KeyList extends SignatureHandler
|
||||
{
|
||||
protected $signature = "toby klucze";
|
||||
|
||||
protected $description = "Lista wszystkich kluczy";
|
||||
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$temp = [];
|
||||
|
||||
foreach (Key::orderBy("id")->get() as $key) {
|
||||
$temp[] = "Klucz nr {$key->id} - <@{$key->user->profile->slack_id}>";
|
||||
}
|
||||
|
||||
|
||||
return $this->respondToSlack(implode("\n", $temp))
|
||||
->displayResponseToEveryoneOnChannel();
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,10 @@ use Toby\Eloquent\Models\YearPeriod;
|
||||
|
||||
class VacationDaysCalculator
|
||||
{
|
||||
public function calculateDays(YearPeriod $yearPeriod, CarbonInterface $from, CarbonInterface $to): Collection
|
||||
public function calculateDays(CarbonInterface $from, CarbonInterface $to): Collection
|
||||
{
|
||||
$period = CarbonPeriod::create($from, $to);
|
||||
$yearPeriod = YearPeriod::findByYear($from->year);
|
||||
$holidays = $yearPeriod->holidays()->pluck("date");
|
||||
|
||||
$validDays = new Collection();
|
||||
|
||||
@@ -29,7 +29,7 @@ class DoesNotExceedLimitRule implements VacationRequestRule
|
||||
|
||||
$limit = $this->getUserVacationLimit($vacationRequest->user, $vacationRequest->yearPeriod);
|
||||
$vacationDays = $this->getVacationDaysWithLimit($vacationRequest->user, $vacationRequest->yearPeriod);
|
||||
$estimatedDays = $this->vacationDaysCalculator->calculateDays($vacationRequest->yearPeriod, $vacationRequest->from, $vacationRequest->to)->count();
|
||||
$estimatedDays = $this->vacationDaysCalculator->calculateDays($vacationRequest->from, $vacationRequest->to)->count();
|
||||
|
||||
return $limit >= ($vacationDays + $estimatedDays);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class MinimumOneVacationDayRule implements VacationRequestRule
|
||||
public function check(VacationRequest $vacationRequest): bool
|
||||
{
|
||||
return $this->vacationDaysCalculator
|
||||
->calculateDays($vacationRequest->yearPeriod, $vacationRequest->from, $vacationRequest->to)
|
||||
->calculateDays($vacationRequest->from, $vacationRequest->to)
|
||||
->isNotEmpty();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ use Toby\Eloquent\Helpers\ColorGenerator;
|
||||
* @property string $position
|
||||
* @property EmploymentForm $employment_form
|
||||
* @property Carbon $employment_date
|
||||
* @property Carbon $birthday
|
||||
*/
|
||||
class Profile extends Model
|
||||
{
|
||||
@@ -32,6 +33,7 @@ class Profile extends Model
|
||||
protected $casts = [
|
||||
"employment_form" => EmploymentForm::class,
|
||||
"employment_date" => "date",
|
||||
"birthday" => "date",
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
|
||||
@@ -125,6 +125,11 @@ class User extends Authenticatable
|
||||
);
|
||||
}
|
||||
|
||||
public function routeNotificationForSlack()
|
||||
{
|
||||
return $this->profile->slack_id;
|
||||
}
|
||||
|
||||
protected static function newFactory(): UserFactory
|
||||
{
|
||||
return UserFactory::new();
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
<?php
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
declare(strict_types=1);
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
namespace Toby\Infrastructure\Console\Commands;
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
use Carbon\CarbonInterface;
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
use Illuminate\Console\Command;
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
use Illuminate\Support\Carbon;
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
use Illuminate\Support\Collection;
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
use Spatie\SlashCommand\Attachment;
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
use Toby\Domain\Enums\VacationType;
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
use Toby\Domain\VacationTypeConfigRetriever;
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
use Toby\Eloquent\Models\Holiday;
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
use Toby\Eloquent\Models\User;
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
use Toby\Eloquent\Models\Vacation;
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
class SendDailySummaryToSlack extends Command
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
{
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
protected $signature = "toby:slack:daily-summary {--f|force}";
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
protected $description = "Sent daily summary to slack";
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
public function handle(VacationTypeConfigRetriever $configRetriever): void
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
{
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
$now = Carbon::today();
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
if (!$this->option("force") && !$this->shouldHandle($now)) {
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
return;
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
}
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
/** @var Collection $absences */
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
$absences = Vacation::query()
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->with(["user", "vacationRequest"])
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->whereDate("date", $now)
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->approved()
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->whereTypes(VacationType::all()->filter(fn(VacationType $type) => $configRetriever->isVacation($type)))
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->get()
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->map(fn(Vacation $vacation) => $vacation->user->profile->full_name);
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
/** @var Collection $remoteDays */
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
$remoteDays = Vacation::query()
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->with(["user", "vacationRequest"])
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->whereDate("date", $now)
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->approved()
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->whereTypes(VacationType::all()->filter(fn(VacationType $type) => !$configRetriever->isVacation($type)))
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->get()
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->map(fn(Vacation $vacation) => $vacation->user->profile->full_name);
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
$birthdays = User::query()
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->whereRelation("profile", "birthday", $now)
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->get()
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->map(fn(User $user) => $user->profile->full_name);
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
$absencesAttachment = Attachment::create()
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->setTitle("Nieobecności :palm_tree:")
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->setColor('#eab308')
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->setText($absences->isNotEmpty() ? $absences->implode("\n") : "Wszyscy dzisiaj pracują :muscle:");
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
$remoteAttachment = Attachment::create()
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->setTitle("Praca zdalna :house_with_garden:")
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->setColor('#d946ef')
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->setText($remoteDays->isNotEmpty() ? $remoteDays->implode("\n") : "Wszyscy dzisiaj są w biurze :boom:");
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
$birthdayAttachment = Attachment::create()
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->setTitle("Urodziny :birthday:")
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->setColor('#3C5F97')
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->setText($birthdays->isNotEmpty() ? $birthdays->implode("\n") : "Dzisiaj nikt nie ma urodzin :cry:");
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
$baseUrl = config("services.slack.url");
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
$url = "{$baseUrl}/chat.postMessage";
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
Http::withToken(config("services.slack.client_token"))
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
->post($url, [
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
"channel" => config("services.slack.default_channel"),
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
"text" => "Podsumowanie dla dnia {$now->toDisplayString()}",
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
'attachments' => collect([$absencesAttachment, $remoteAttachment, $birthdayAttachment])->map(
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
fn(Attachment $attachment) => $attachment->toArray()
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
)->toArray(),
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
]);
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
}
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
protected function shouldHandle(CarbonInterface $day): bool
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
{
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
$holidays = Holiday::query()->whereDate("date", $day)->pluck("date");
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
if ($day->isWeekend()) {
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
return false;
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
}
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
if ($holidays->contains($day)) {
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
return false;
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
}
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
return true;
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
}
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
}
|
||||
|
These attachments are almost the same as somewhere above. There should be some abstraction for that. These attachments are almost the same as somewhere above. There should be some abstraction for that.
I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it. I think I would prefer to use camelCased model attributes. It's not for this PR, but please think about it.
|
||||
@@ -14,7 +14,7 @@ class CalculateVacationDaysController extends Controller
|
||||
{
|
||||
public function __invoke(CalculateVacationDaysRequest $request, VacationDaysCalculator $calculator): JsonResponse
|
||||
{
|
||||
$days = $calculator->calculateDays($request->yearPeriod(), $request->from(), $request->to());
|
||||
$days = $calculator->calculateDays($request->from(), $request->to());
|
||||
|
||||
return new JsonResponse($days->map(fn(Carbon $day) => $day->toDateString())->all());
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ class UserRequest extends FormRequest
|
||||
"position" => ["required"],
|
||||
"employmentForm" => ["required", new Enum(EmploymentForm::class)],
|
||||
"employmentDate" => ["required", "date_format:Y-m-d"],
|
||||
"birthday" => ["nullable", "date_format:Y-m-d"],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -41,6 +42,7 @@ class UserRequest extends FormRequest
|
||||
"position" => $this->get("position"),
|
||||
"employment_form" => $this->get("employmentForm"),
|
||||
"employment_date" => $this->get("employmentDate"),
|
||||
"birthday" => $this->get("birthday"),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ class UserFormDataResource extends JsonResource
|
||||
"position" => $this->profile->position,
|
||||
"employmentForm" => $this->profile->employment_form,
|
||||
"employmentDate" => $this->profile->employment_date->toDateString(),
|
||||
"birthday" => $this->profile->birthday->toDateString(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ return [
|
||||
Illuminate\Validation\ValidationServiceProvider::class,
|
||||
Illuminate\View\ViewServiceProvider::class,
|
||||
Barryvdh\DomPDF\ServiceProvider::class,
|
||||
Spatie\SlashCommand\SlashCommandServiceProvider::class,
|
||||
Toby\Architecture\Providers\AppServiceProvider::class,
|
||||
Toby\Architecture\Providers\AuthServiceProvider::class,
|
||||
Toby\Architecture\Providers\EventServiceProvider::class,
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
<?php
|
||||
|
||||
use Toby\Domain\Slack\GiveKeysTo;
|
||||
use Toby\Domain\Slack\HomeOffice;
|
||||
use Toby\Domain\Slack\KeyList;
|
||||
use Toby\Domain\Slack\TakeKeysFrom;
|
||||
declare(strict_types=1);
|
||||
|
||||
use Toby\Domain\Slack\Handlers\CatchAll;
|
||||
use Toby\Domain\Slack\Handlers\DailySummary;
|
||||
use Toby\Domain\Slack\Handlers\GiveKeysTo;
|
||||
use Toby\Domain\Slack\Handlers\Help;
|
||||
use Toby\Domain\Slack\Handlers\HomeOffice;
|
||||
use Toby\Domain\Slack\Handlers\KeyList;
|
||||
use Toby\Domain\Slack\Handlers\SaySomething;
|
||||
use Toby\Domain\Slack\Handlers\TakeKeysFrom;
|
||||
|
||||
return [
|
||||
'url' => 'api/slack',
|
||||
@@ -14,7 +20,9 @@ return [
|
||||
GiveKeysTo::class,
|
||||
KeyList::class,
|
||||
HomeOffice::class,
|
||||
Spatie\SlashCommand\Handlers\Help::class,
|
||||
Spatie\SlashCommand\Handlers\CatchAll::class,
|
||||
DailySummary::class,
|
||||
SaySomething::class,
|
||||
Help::class,
|
||||
CatchAll::class
|
||||
],
|
||||
];
|
||||
|
||||
@@ -8,4 +8,9 @@ return [
|
||||
"client_secret" => env("GOOGLE_CLIENT_SECRET"),
|
||||
"redirect" => env("GOOGLE_REDIRECT"),
|
||||
],
|
||||
"slack" => [
|
||||
"url" => "https://slack.com/api",
|
||||
"client_token" => env("SLACK_CLIENT_TOKEN"),
|
||||
"default_channel" => env("SLACK_DEFAULT_CHANNEL"),
|
||||
],
|
||||
];
|
||||
|
||||
@@ -23,6 +23,7 @@ class ProfileFactory extends Factory
|
||||
"employment_form" => $this->faker->randomElement(EmploymentForm::cases()),
|
||||
"position" => $this->faker->jobTitle(),
|
||||
"employment_date" => Carbon::createFromInterface($this->faker->dateTimeBetween("2020-10-27"))->toDateString(),
|
||||
"birthday" => Carbon::createFromInterface($this->faker->dateTimeBetween("1970-01-01", "1998-01-01"))->toDateString(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,15 @@ return new class() extends Migration {
|
||||
{
|
||||
Schema::table("profiles", function (Blueprint $table): void {
|
||||
$table->string("slack_id")->nullable();
|
||||
$table->date("birthday")->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table("profiles", function (Blueprint $table): void {
|
||||
$table->string("slack_id");
|
||||
$table->dropColumn("slack_id");
|
||||
$table->dropColumn("birthday");
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -234,6 +234,29 @@
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="items-center py-4 sm:grid sm:grid-cols-3">
|
||||
<label
|
||||
for="birthday"
|
||||
class="block text-sm font-medium text-gray-700 sm:mt-px"
|
||||
>
|
||||
Data urodzenia
|
||||
</label>
|
||||
<div class="mt-1 sm:col-span-2 sm:mt-0">
|
||||
<FlatPickr
|
||||
id="birthday"
|
||||
v-model="form.birthday"
|
||||
placeholder="Wybierz datę"
|
||||
class="block w-full max-w-lg rounded-md shadow-sm sm:text-sm"
|
||||
:class="{ 'border-red-300 text-red-900 focus:outline-none focus:ring-red-500 focus:border-red-500': form.errors.birthday, 'focus:ring-blumilk-500 focus:border-blumilk-500 sm:text-sm border-gray-300': !form.errors.birthday }"
|
||||
/>
|
||||
<p
|
||||
v-if="form.errors.birthday"
|
||||
class="mt-2 text-sm text-red-600"
|
||||
>
|
||||
{{ form.errors.birthday }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end py-3">
|
||||
<div class="space-x-3">
|
||||
<InertiaLink
|
||||
@@ -274,6 +297,7 @@ const form = useForm({
|
||||
role: props.roles[0],
|
||||
position: null,
|
||||
employmentDate: null,
|
||||
birthday: null,
|
||||
})
|
||||
|
||||
function createUser() {
|
||||
|
||||
@@ -241,6 +241,29 @@
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="items-center py-4 sm:grid sm:grid-cols-3">
|
||||
<label
|
||||
for="birthday"
|
||||
class="block text-sm font-medium text-gray-700 sm:mt-px"
|
||||
>
|
||||
Data urodzenia
|
||||
</label>
|
||||
<div class="mt-1 sm:col-span-2 sm:mt-0">
|
||||
<FlatPickr
|
||||
id="birthday"
|
||||
v-model="form.birthday"
|
||||
placeholder="Wybierz datę"
|
||||
class="block w-full max-w-lg rounded-md shadow-sm sm:text-sm"
|
||||
:class="{ 'border-red-300 text-red-900 focus:outline-none focus:ring-red-500 focus:border-red-500': form.errors.birthday, 'focus:ring-blumilk-500 focus:border-blumilk-500 sm:text-sm border-gray-300': !form.errors.birthday }"
|
||||
/>
|
||||
<p
|
||||
v-if="form.errors.birthday"
|
||||
class="mt-2 text-sm text-red-600"
|
||||
>
|
||||
{{ form.errors.birthday }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end py-3">
|
||||
<div class="space-x-3">
|
||||
<InertiaLink
|
||||
@@ -282,6 +305,7 @@ const form = useForm({
|
||||
position: props.user.position,
|
||||
employmentForm: props.employmentForms.find(form => form.value === props.user.employmentForm),
|
||||
employmentDate: props.user.employmentDate,
|
||||
birthday: props.user.birthday,
|
||||
})
|
||||
|
||||
function editUser() {
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
"All rights reserved.": "Wszelkie prawa zastrzeżone",
|
||||
"Show vacation request": "Pokaż wniosek",
|
||||
"Vacation request :title has been created" : "Wniosek :title został utworzony",
|
||||
"The vacation request :title has been created correctly in the :appName.": "W systemie :appName został poprawnie utworzony wniosek urlopowy :title.",
|
||||
"The vacation request :title from user :requester has been created sucessfully.": "Wniosek :title użytkownika :requester został utworzony pomyślnie.",
|
||||
"Vacation type: :type": "Rodzaj wniosku: :type",
|
||||
"From :from to :to (number of days: :days)": "Od :from do :to (liczba dni: :days)",
|
||||
"Click here for details": "Kliknij, aby zobaczyć szczegóły",
|
||||
@@ -67,7 +67,7 @@
|
||||
"Vacation request :title has been :status": "Wniosek :title został :status",
|
||||
"The vacation request :title from user :requester has been :status.": "Wniosek urlopowy :title użytkownika :requester został :status.",
|
||||
"Vacation request :title has been created on your behalf": "Wniosek urlopowy :title został utworzony w Twoim imieniu",
|
||||
"The vacation request :title has been created correctly by user :creator on your behalf in the :appName.": "W systemie :appName został poprawnie utworzony wniosek urlopowy :title w Twoim imieniu przez użytkownika :creator.",
|
||||
"The vacation request :title has been created successfully by user :creator on your behalf.": "Wniosek urlopowy :title został pomyślnie utworzony w Twoim imieniu przez użytkownika :creator.",
|
||||
"Key no :number has been created.": "Klucz nr :number został utworzony.",
|
||||
"Key no :number has been deleted.": "Klucz nr :number został usunięty.",
|
||||
"Key no :number has been taken from :user.": "Klucz nr :number został zabrany użytkownikowi :user.",
|
||||
|
||||
82
tests/Unit/SendDailySummaryToSlackTest.php
Normal file
@@ -0,0 +1,82 @@
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
<?php
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
declare(strict_types=1);
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
namespace Tests\Unit;
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
use Illuminate\Support\Carbon;
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
use Illuminate\Support\Facades\Http;
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
use Tests\TestCase;
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
use Tests\Traits\InteractsWithYearPeriods;
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
use Toby\Eloquent\Models\Holiday;
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
use Toby\Infrastructure\Console\Commands\SendDailySummaryToSlack;
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
class SendDailySummaryToSlackTest extends TestCase
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
{
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
use RefreshDatabase;
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
use InteractsWithYearPeriods;
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
protected function setUp(): void
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
{
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
parent::setUp();
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
Http::fake();
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
$this->createCurrentYearPeriod();
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
}
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
public function testCommandSendsMessageToSlackIfWeekday(): void
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
{
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
$weekDay = Carbon::create(2022, 4, 22);
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
$this->assertTrue($weekDay->isWeekday());
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
$this->travelTo($weekDay);
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
$this->artisan(SendDailySummaryToSlack::class)
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
->execute();
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
Http::assertSentCount(1);
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
}
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
public function testCommandDoesntSendIfIsWeekend(): void
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
{
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
$weekend = Carbon::create(2022, 4, 23);
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
$this->assertTrue($weekend->isWeekend());
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
$this->travelTo($weekend);
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
$this->artisan(SendDailySummaryToSlack::class)
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
->execute();
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
Http::assertNothingSent();
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
}
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
public function testCommandDoesntSendIfIsHoliday(): void
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
{
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
$holiday = Holiday::factory(["date" => Carbon::create(2022, 4, 22)])->create();
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
$this->assertDatabaseHas("holidays", [
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
"date" => $holiday->date->toDateString(),
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
]);
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
$this->travelTo(Carbon::create(2022, 4, 22));
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
$this->artisan(SendDailySummaryToSlack::class)
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
->execute();
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
Http::assertNothingSent();
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
}
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
public function testCommandForceSendsMessageEvenIsWeekendOrHoliday(): void
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
{
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
$weekend = Carbon::create(2022, 4, 23);
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
$this->assertTrue($weekend->isWeekend());
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
$this->travelTo($weekend);
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
$this->artisan(SendDailySummaryToSlack::class, ["--force" => true])
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
->execute();
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
Http::assertSentCount(1);
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
}
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
}
|
||||
```suggestion
public function testCommandDoesntSendMessageIfWeekend(): void
```
```suggestion
public function testCommandDoesntSendMessageIfHoliday(): void
```
|
||||
Can you type
$notifiable?Can you type
$notifiable?Hm, I don't if I wouldn't put his to Infrastucture directory.
Hm, I don't if I wouldn't put his to Infrastucture directory.
Could you extract this config to separate method? It would make further testing easier, I think.
Could you extract this config to separate method? It would make further testing easier, I think.
In general, it can be anything that uses trait
NotifiableIn general, it can be anything that uses trait
NotifiableOh no, maybe you could add some interface fot that?
Oh no, maybe you could add some interface fot that?