#116 - integration with slack #129
@@ -9,19 +9,19 @@ use Illuminate\Notifications\ChannelManager;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Toby\Domain\Slack\Channels\SlackApiChannel;
|
||||
use Toby\Infrastructure\Slack\Channels\SlackApiChannel;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
Notification::resolved(function (ChannelManager $service): void {
|
||||
$service->extend("slack", fn(Application $app) => $app->make(SlackApiChannel::class));
|
||||
$service->extend("slack", fn(Application $app): SlackApiChannel => $app->make(SlackApiChannel::class));
|
||||
});
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
Carbon::macro("toDisplayString", fn() => $this->translatedFormat("d.m.Y"));
|
||||
Carbon::macro("toDisplayString", fn(): string => $this->translatedFormat("d.m.Y"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,10 +30,10 @@ class AuthServiceProvider extends ServiceProvider
|
||||
}
|
||||
});
|
||||
|
||||
Gate::define("manageUsers", fn(User $user) => $user->role === Role::AdministrativeApprover);
|
||||
Gate::define("manageHolidays", fn(User $user) => $user->role === Role::AdministrativeApprover);
|
||||
Gate::define("manageVacationLimits", fn(User $user) => $user->role === Role::AdministrativeApprover);
|
||||
Gate::define("generateTimesheet", fn(User $user) => $user->role === Role::AdministrativeApprover);
|
||||
Gate::define("listMonthlyUsage", fn(User $user) => $user->role === Role::AdministrativeApprover);
|
||||
Gate::define("manageUsers", fn(User $user): bool => $user->role === Role::AdministrativeApprover);
|
||||
Gate::define("manageHolidays", fn(User $user): bool => $user->role === Role::AdministrativeApprover);
|
||||
Gate::define("manageVacationLimits", fn(User $user): bool => $user->role === Role::AdministrativeApprover);
|
||||
Gate::define("generateTimesheet", fn(User $user): bool => $user->role === Role::AdministrativeApprover);
|
||||
Gate::define("listMonthlyUsage", fn(User $user): bool => $user->role === Role::AdministrativeApprover);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,6 @@ class RouteServiceProvider extends ServiceProvider
|
||||
|
||||
protected function configureRateLimiting(): void
|
||||
{
|
||||
RateLimiter::for("api", fn(Request $request) => Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()));
|
||||
RateLimiter::for("api", fn(Request $request): Limit => Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,6 @@ class CalendarGenerator
|
||||
->approved()
|
||||
->with("vacationRequest")
|
||||
->get()
|
||||
->groupBy(fn(Vacation $vacation) => $vacation->date->toDateString());
|
||||
->groupBy(fn(Vacation $vacation): string => $vacation->date->toDateString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@ class DailySummaryRetriever
|
||||
|
krzysztofrewak
commented
Review
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => $this->configRetriever->isVacation($type)))
```
krzysztofrewak
commented
Review
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => $this->configRetriever->isVacation($type)))
```
krzysztofrewak
commented
Review
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => !$this->configRetriever->isVacation($type)))
```
krzysztofrewak
commented
Review
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => !$this->configRetriever->isVacation($type)))
```
|
||||
->with(["user", "vacationRequest"])
|
||||
->whereDate("date", $date)
|
||||
->approved()
|
||||
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => $this->configRetriever->isVacation($type)))
|
||||
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => $this->configRetriever->isVacation($type)))
```
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => !$this->configRetriever->isVacation($type)))
```
|
||||
->whereTypes(
|
||||
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => $this->configRetriever->isVacation($type)))
```
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => !$this->configRetriever->isVacation($type)))
```
|
||||
VacationType::all()->filter(fn(VacationType $type): bool => $this->configRetriever->isVacation($type)),
|
||||
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => $this->configRetriever->isVacation($type)))
```
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => !$this->configRetriever->isVacation($type)))
```
|
||||
)
|
||||
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => $this->configRetriever->isVacation($type)))
```
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => !$this->configRetriever->isVacation($type)))
```
|
||||
->get();
|
||||
}
|
||||
|
||||
@@ -32,7 +34,9 @@ class DailySummaryRetriever
|
||||
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => $this->configRetriever->isVacation($type)))
```
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => $this->configRetriever->isVacation($type)))
```
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => !$this->configRetriever->isVacation($type)))
```
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => !$this->configRetriever->isVacation($type)))
```
|
||||
->with(["user", "vacationRequest"])
|
||||
->whereDate("date", $date)
|
||||
->approved()
|
||||
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => !$this->configRetriever->isVacation($type)))
|
||||
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => $this->configRetriever->isVacation($type)))
```
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => !$this->configRetriever->isVacation($type)))
```
|
||||
->whereTypes(
|
||||
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => $this->configRetriever->isVacation($type)))
```
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => !$this->configRetriever->isVacation($type)))
```
|
||||
VacationType::all()->filter(fn(VacationType $type): bool => !$this->configRetriever->isVacation($type)),
|
||||
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => $this->configRetriever->isVacation($type)))
```
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => !$this->configRetriever->isVacation($type)))
```
|
||||
)
|
||||
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => $this->configRetriever->isVacation($type)))
```
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => !$this->configRetriever->isVacation($type)))
```
|
||||
->get();
|
||||
}
|
||||
|
||||
|
||||
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => $this->configRetriever->isVacation($type)))
```
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => $this->configRetriever->isVacation($type)))
```
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => !$this->configRetriever->isVacation($type)))
```
```suggestion
->whereTypes(VacationType::all()->filter(fn(VacationType $type): bool => !$this->configRetriever->isVacation($type)))
```
|
||||
@@ -21,7 +21,7 @@ enum EmploymentForm: string
|
||||
$cases = collect(EmploymentForm::cases());
|
||||
|
||||
return $cases->map(
|
||||
fn(EmploymentForm $enum) => [
|
||||
fn(EmploymentForm $enum): array => [
|
||||
"label" => $enum->label(),
|
||||
"value" => $enum->value,
|
||||
],
|
||||
|
||||
@@ -21,7 +21,7 @@ enum Role: string
|
||||
$cases = collect(Role::cases());
|
||||
|
||||
return $cases->map(
|
||||
fn(Role $enum) => [
|
||||
fn(Role $enum): array => [
|
||||
"label" => $enum->label(),
|
||||
"value" => $enum->value,
|
||||
],
|
||||
|
||||
@@ -30,7 +30,7 @@ enum VacationType: string
|
||||
$cases = VacationType::all();
|
||||
|
||||
return $cases->map(
|
||||
fn(VacationType $enum) => [
|
||||
fn(VacationType $enum): array => [
|
||||
"label" => $enum->label(),
|
||||
"value" => $enum->value,
|
||||
],
|
||||
|
||||
11
app/Domain/Notifications/Channels.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Notifications;
|
||||
|
||||
class Channels
|
||||
{
|
||||
public const MAIL = "mail";
|
||||
public const SLACK = "slack";
|
||||
}
|
||||
@@ -19,10 +19,10 @@ class KeyHasBeenGivenNotification extends Notification
|
||||
|
Maybe these Maybe these `"slack"` and other channels could be gathered somewhere and used as constants or enums?
Maybe these Maybe these `"slack"` and other channels could be gathered somewhere and used as constants or enums?
|
||||
|
||||
public function via(): array
|
||||
{
|
||||
return ["slack"];
|
||||
|
Maybe these Maybe these `"slack"` and other channels could be gathered somewhere and used as constants or enums?
|
||||
return [Channels::SLACK];
|
||||
|
Maybe these Maybe these `"slack"` and other channels could be gathered somewhere and used as constants or enums?
|
||||
}
|
||||
|
||||
public function toSlack($notifiable): string
|
||||
|
Maybe these Maybe these `"slack"` and other channels could be gathered somewhere and used as constants or enums?
|
||||
public function toSlack(Notifiable $notifiable): string
|
||||
|
Maybe these Maybe these `"slack"` and other channels could be gathered somewhere and used as constants or enums?
|
||||
{
|
||||
return __(":sender gives key no :key to :recipient", [
|
||||
"sender" => $this->getName($this->sender),
|
||||
|
||||
|
Maybe these Maybe these `"slack"` and other channels could be gathered somewhere and used as constants or enums?
Maybe these Maybe these `"slack"` and other channels could be gathered somewhere and used as constants or enums?
|
||||
@@ -19,10 +19,10 @@ class KeyHasBeenTakenNotification extends Notification
|
||||
|
||||
public function via(): array
|
||||
{
|
||||
return ["slack"];
|
||||
return [Channels::SLACK];
|
||||
}
|
||||
|
||||
public function toSlack($notifiable): string
|
||||
public function toSlack(Notifiable $notifiable): string
|
||||
{
|
||||
return __(":recipient takes key no :key from :sender", [
|
||||
"recipient" => $this->getName($this->recipient),
|
||||
|
||||
10
app/Domain/Notifications/Notifiable.php
Normal file
@@ -0,0 +1,10 @@
|
||||
|
👀 :eyes:
👀 :eyes:
|
||||
<?php
|
||||
|
👀 :eyes:
|
||||
|
||||
|
👀 :eyes:
|
||||
declare(strict_types=1);
|
||||
|
👀 :eyes:
|
||||
|
||||
|
👀 :eyes:
|
||||
namespace Toby\Domain\Notifications;
|
||||
|
👀 :eyes:
|
||||
|
||||
|
👀 :eyes:
|
||||
interface Notifiable
|
||||
|
👀 :eyes:
|
||||
{
|
||||
|
👀 :eyes:
|
||||
public function notify($instance);
|
||||
|
👀 :eyes:
|
||||
}
|
||||
|
👀 :eyes:
|
||||
@@ -20,7 +20,7 @@ class VacationRequestCreatedNotification extends Notification
|
||||
|
||||
public function via(): array
|
||||
{
|
||||
return ["mail", "slack"];
|
||||
return [Channels::MAIL, Channels::SLACK];
|
||||
}
|
||||
|
||||
public function toSlack(): string
|
||||
|
||||
@@ -22,7 +22,7 @@ class VacationRequestStatusChangedNotification extends Notification
|
||||
|
||||
public function via(): array
|
||||
{
|
||||
return ["mail", "slack"];
|
||||
return [Channels::MAIL, Channels::SLACK];
|
||||
}
|
||||
|
||||
public function toSlack(): string
|
||||
|
||||
@@ -23,7 +23,7 @@ class VacationRequestWaitsForApprovalNotification extends Notification
|
||||
|
||||
public function via(): array
|
||||
{
|
||||
return ["mail", "slack"];
|
||||
return [Channels::MAIL, Channels::SLACK];
|
||||
}
|
||||
|
||||
public function toSlack(): string
|
||||
|
||||
@@ -26,7 +26,7 @@ class PolishHolidaysRetriever
|
||||
|
||||
protected function prepareHolidays(array $holidays): Collection
|
||||
{
|
||||
return collect($holidays)->map(fn(Holiday $holiday) => [
|
||||
return collect($holidays)->map(fn(Holiday $holiday): array => [
|
||||
"name" => $holiday->getName([static::LANG_KEY]),
|
||||
"date" => Carbon::createFromTimestamp($holiday->getTimestamp()),
|
||||
])->values();
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
|
Can you type Can you type `$notifiable`?
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.
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.
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`
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?
Oh no, maybe you could add some interface fot that? Oh no, maybe you could add some interface fot that?
|
||||
<?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($notifiable),
|
||||
|
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?
|
||||
@@ -1,55 +0,0 @@
|
||||
```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 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 Toby\Domain\DailySummaryRetriever;
|
||||
```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?
|
||||
protected $description = "Codzienne 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?
|
||||
$dailySummaryRetriever = app()->make(DailySummaryRetriever::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?
|
||||
$absences = $dailySummaryRetriever->getAbsences($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?
|
||||
->map(fn(Vacation $vacation): string => $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?
|
||||
$remoteDays = $dailySummaryRetriever->getRemoteDays($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?
|
||||
->map(fn(Vacation $vacation): string => $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 = $dailySummaryRetriever->getBirthdays($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?
|
||||
->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?
|
||||
|
||||
```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 :sunny:")
|
||||
```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("#527aba")
|
||||
```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?
|
||||
}
|
||||
```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?
|
||||
@@ -18,7 +18,7 @@ class TimesheetExport implements WithMultipleSheets
|
||||
public function sheets(): array
|
||||
{
|
||||
return $this->users
|
||||
->map(fn(User $user) => new TimesheetPerUserSheet($user, $this->month, $this->types))
|
||||
->map(fn(User $user): TimesheetPerUserSheet => new TimesheetPerUserSheet($user, $this->month, $this->types))
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
@@ -193,8 +193,8 @@ class TimesheetPerUserSheet implements WithTitle, WithHeadings, WithEvents, With
|
||||
->get()
|
||||
->groupBy(
|
||||
[
|
||||
fn(Vacation $vacation) => $vacation->date->toDateString(),
|
||||
fn(Vacation $vacation) => $vacation->vacationRequest->type->value,
|
||||
fn(Vacation $vacation): string => $vacation->date->toDateString(),
|
||||
fn(Vacation $vacation): string => $vacation->vacationRequest->type->value,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ class UserVacationStatsRetriever
|
||||
->states(VacationRequestStatesRetriever::successStates()),
|
||||
)
|
||||
->get()
|
||||
->groupBy(fn(Vacation $vacation) => strtolower($vacation->date->englishMonth))
|
||||
->map(fn(Collection $items) => $items->count());
|
||||
->groupBy(fn(Vacation $vacation): string => strtolower($vacation->date->englishMonth))
|
||||
->map(fn(Collection $items): int => $items->count());
|
||||
}
|
||||
|
||||
public function getPendingVacationDays(User $user, YearPeriod $yearPeriod): int
|
||||
@@ -107,13 +107,13 @@ class UserVacationStatsRetriever
|
||||
{
|
||||
$types = VacationType::all();
|
||||
|
||||
return $types->filter(fn(VacationType $type) => $this->configRetriever->hasLimit($type));
|
||||
return $types->filter(fn(VacationType $type): bool => $this->configRetriever->hasLimit($type));
|
||||
}
|
||||
|
||||
protected function getNotLimitableVacationTypes(): Collection
|
||||
{
|
||||
$types = VacationType::all();
|
||||
|
||||
return $types->filter(fn(VacationType $type) => !$this->configRetriever->hasLimit($type));
|
||||
return $types->filter(fn(VacationType $type): bool => !$this->configRetriever->hasLimit($type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,6 @@ class DoesNotExceedLimitRule implements VacationRequestRule
|
||||
{
|
||||
$types = VacationType::all();
|
||||
|
||||
return $types->filter(fn(VacationType $type) => $this->configRetriever->hasLimit($type));
|
||||
return $types->filter(fn(VacationType $type): bool => $this->configRetriever->hasLimit($type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class VacationTypeCanBeSelected implements VacationRequestRule
|
||||
$employmentForm = $vacationRequest->user->profile->employment_form;
|
||||
|
||||
$availableTypes = VacationType::all()
|
||||
->filter(fn(VacationType $type) => $this->configRetriever->isAvailableFor($type, $employmentForm));
|
||||
->filter(fn(VacationType $type): bool => $this->configRetriever->isAvailableFor($type, $employmentForm));
|
||||
|
||||
return $availableTypes->contains($vacationRequest->type);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class YearPeriodRetriever
|
||||
|
||||
$years = YearPeriod::all();
|
||||
|
||||
$navigation = $years->map(fn(YearPeriod $yearPeriod) => $this->toNavigation($yearPeriod));
|
||||
$navigation = $years->map(fn(YearPeriod $yearPeriod): array => $this->toNavigation($yearPeriod));
|
||||
|
||||
return [
|
||||
"current" => $this->toNavigation($current),
|
||||
|
||||
@@ -9,12 +9,13 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Toby\Domain\Notifications\Notifiable as NotifiableInterface;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property User $user
|
||||
*/
|
||||
class Key extends Model
|
||||
class Key extends Model implements NotifiableInterface
|
||||
{
|
||||
use HasFactory;
|
||||
use Notifiable;
|
||||
|
||||
@@ -15,6 +15,7 @@ use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Collection;
|
||||
use Toby\Domain\Enums\EmploymentForm;
|
||||
use Toby\Domain\Enums\Role;
|
||||
use Toby\Domain\Notifications\Notifiable as NotifiableInterface;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
@@ -26,7 +27,7 @@ use Toby\Domain\Enums\Role;
|
||||
* @property Collection $vacationRequests
|
||||
* @property Collection $vacations
|
||||
*/
|
||||
class User extends Authenticatable
|
||||
class User extends Authenticatable implements NotifiableInterface
|
||||
{
|
||||
use HasFactory;
|
||||
use Notifiable;
|
||||
@@ -99,7 +100,7 @@ class User extends Authenticatable
|
||||
->where("email", "ILIKE", "%{$text}%")
|
||||
->orWhereRelation(
|
||||
"profile",
|
||||
fn(Builder $query) => $query
|
||||
fn(Builder $query): Builder => $query
|
||||
->where("first_name", "ILIKE", "%{$text}%")
|
||||
->orWhere("last_name", "ILIKE", "%{$text}%"),
|
||||
);
|
||||
|
||||
@@ -7,12 +7,13 @@ 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.
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.
|
||||
use Carbon\CarbonInterface;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Carbon;
|
||||
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;
|
||||
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\DailySummaryRetriever;
|
||||
use Toby\Eloquent\Models\Holiday;
|
||||
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.
|
||||
use Toby\Infrastructure\Slack\Elements\AbsencesAttachment;
|
||||
|
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\Infrastructure\Slack\Elements\BirthdaysAttachment;
|
||||
|
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\Infrastructure\Slack\Elements\RemotesAttachment;
|
||||
|
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
|
||||
{
|
||||
@@ -27,40 +28,17 @@ 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.
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.
|
||||
return;
|
||||
}
|
||||
|
||||
$absences = $dailySummaryRetriever->getAbsences($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.
|
||||
->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.
|
||||
$attachments = new 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.
|
||||
new AbsencesAttachment($dailySummaryRetriever->getAbsences($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.
|
||||
new RemotesAttachment($dailySummaryRetriever->getRemoteDays($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.
|
||||
new BirthdaysAttachment($dailySummaryRetriever->getBirthdays($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.
|
||||
]);
|
||||
|
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 = $dailySummaryRetriever->getRemoteDays($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.
|
||||
->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 = $dailySummaryRetriever->getBirthdays($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.
|
||||
->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("#527aba")
|
||||
|
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.
|
||||
Http::withToken($this->getSlackClientToken())
|
||||
|
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($this->getUrl(), [
|
||||
|
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" => $this->getSlackChannel(),
|
||||
|
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()}",
|
||||
"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.
|
||||
"attachments" => $attachments,
|
||||
|
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.
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -78,4 +56,24 @@ 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.
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.
|
||||
|
||||
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.
|
||||
protected function getUrl(): string
|
||||
|
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 "{$this->getSlackBaseUrl()}/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.
|
||||
|
||||
|
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 getSlackBaseUrl(): string
|
||||
|
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 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.
|
||||
}
|
||||
|
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 getSlackClientToken(): string
|
||||
|
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 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.
|
||||
}
|
||||
|
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 getSlackChannel(): string
|
||||
|
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 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.
|
||||
}
|
||||
|
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.
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.
|
||||
@@ -16,6 +16,6 @@ class CalculateVacationDaysController extends Controller
|
||||
{
|
||||
$days = $calculator->calculateDays($request->from(), $request->to());
|
||||
|
||||
return new JsonResponse($days->map(fn(Carbon $day) => $day->toDateString())->all());
|
||||
return new JsonResponse($days->map(fn(Carbon $day): string => $day->toDateString())->all());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ class GetAvailableVacationTypesController extends Controller
|
||||
$user = User::query()->find($request->get("user"));
|
||||
|
||||
$types = VacationType::all()
|
||||
->filter(fn(VacationType $type) => $configRetriever->isAvailableFor($type, $user->profile->employment_form))
|
||||
->map(fn(VacationType $type) => [
|
||||
->filter(fn(VacationType $type): bool => $configRetriever->isAvailableFor($type, $user->profile->employment_form))
|
||||
->map(fn(VacationType $type): array => [
|
||||
"label" => $type->label(),
|
||||
"value" => $type->value,
|
||||
])
|
||||
|
||||
@@ -35,8 +35,10 @@ class TimesheetController extends Controller
|
||||
|
||||
$types = VacationType::all()
|
||||
->filter(
|
||||
fn(VacationType $type) => $configRetriever->isAvailableFor($type, EmploymentForm::EmploymentContract)
|
||||
&& $configRetriever->isVacation($type),
|
||||
fn(VacationType $type): bool => $configRetriever->isAvailableFor(
|
||||
$type,
|
||||
EmploymentForm::EmploymentContract,
|
||||
) && $configRetriever->isVacation($type),
|
||||
);
|
||||
|
||||
$filename = "{$carbonMonth->translatedFormat("F Y")}.xlsx";
|
||||
|
||||
@@ -30,7 +30,7 @@ class VacationLimitController extends Controller
|
||||
->sortBy(fn(VacationLimit $limit): string => "{$limit->user->profile->last_name} {$limit->user->profile->first_name}")
|
||||
->values();
|
||||
|
||||
$limitsResource = $limits->map(fn(VacationLimit $limit) => [
|
||||
$limitsResource = $limits->map(fn(VacationLimit $limit): array => [
|
||||
"id" => $limit->id,
|
||||
"user" => new UserResource($limit->user),
|
||||
"hasVacation" => $limit->hasVacation(),
|
||||
|
||||
@@ -32,7 +32,7 @@ class HandleInertiaRequests extends Middleware
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
return fn() => [
|
||||
return fn(): array => [
|
||||
"user" => $user ? new UserResource($user) : null,
|
||||
"can" => [
|
||||
"manageVacationLimits" => $user ? $user->can("manageVacationLimits") : false,
|
||||
@@ -45,7 +45,7 @@ class HandleInertiaRequests extends Middleware
|
||||
|
||||
protected function getFlashData(Request $request): Closure
|
||||
{
|
||||
return fn() => [
|
||||
return fn(): array => [
|
||||
"success" => $request->session()->get("success"),
|
||||
"error" => $request->session()->get("error"),
|
||||
"info" => $request->session()->get("info"),
|
||||
|
||||
36
app/Infrastructure/Slack/Channels/SlackApiChannel.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Infrastructure\Slack\Channels;
|
||||
|
||||
use Illuminate\Http\Client\Response;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Toby\Domain\Notifications\Notifiable;
|
||||
|
||||
class SlackApiChannel
|
||||
{
|
||||
public function send(Notifiable $notifiable, Notification $notification): Response
|
||||
{
|
||||
$baseUrl = $this->getBaseUrl();
|
||||
$url = "{$baseUrl}/chat.postMessage";
|
||||
$channel = $notifiable->routeNotificationFor("slack", $notification);
|
||||
|
||||
return Http::withToken($this->getClientToken())
|
||||
->post($url, [
|
||||
"channel" => $channel,
|
||||
"text" => $notification->toSlack($notifiable),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getClientToken(): string
|
||||
{
|
||||
return config("services.slack.client_token");
|
||||
}
|
||||
|
||||
protected function getBaseUrl(): string
|
||||
{
|
||||
return config("services.slack.url");
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack;
|
||||
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
|
||||
namespace Toby\Infrastructure\Slack;
|
||||
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Http\Request as IlluminateRequest;
|
||||
@@ -11,6 +11,7 @@ use Illuminate\Support\Collection;
|
||||
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Spatie\SlashCommand\Attachment;
|
||||
use Spatie\SlashCommand\Controller as SlackController;
|
||||
use Spatie\SlashCommand\Exceptions\InvalidRequest;
|
||||
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
|
||||
use Spatie\SlashCommand\Exceptions\RequestCouldNotBeHandled;
|
||||
use Spatie\SlashCommand\Exceptions\SlackSlashCommandException;
|
||||
use Spatie\SlashCommand\Response;
|
||||
@@ -18,11 +19,11 @@ use Spatie\SlashCommand\Response;
|
||||
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
|
||||
class Controller extends SlackController
|
||||
{
|
||||
/**
|
||||
* @throws RequestCouldNotBeHandled
|
||||
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
|
||||
* @throws InvalidRequest|RequestCouldNotBeHandled
|
||||
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
|
||||
*/
|
||||
public function getResponse(IlluminateRequest $request): IlluminateResponse
|
||||
{
|
||||
$this->guardAgainstInvalidRequest($request);
|
||||
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
|
||||
$this->verifyWithSigning($request);
|
||||
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
|
||||
|
||||
$handler = $this->determineHandler();
|
||||
|
||||
@@ -43,13 +44,13 @@ class Controller extends SlackController
|
||||
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
|
||||
{
|
||||
$errors = (new Collection($exception->errors()))
|
||||
->map(
|
||||
fn(array $message) => Attachment::create()
|
||||
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
|
||||
fn(array $message): Attachment => Attachment::create()
|
||||
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
|
||||
->setColor("danger")
|
||||
->setText($message[0]),
|
||||
);
|
||||
|
||||
return Response::create($this->request)
|
||||
->withText(":x: Komenda `/{$this->request->command} {$this->request->text}` jest niepoprawna:")
|
||||
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
|
||||
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawna:")
|
||||
```suggestion
->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:")
```
|
||||
->withAttachments($errors->all());
|
||||
}
|
||||
}
|
||||
22
app/Infrastructure/Slack/Elements/AbsencesAttachment.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Infrastructure\Slack\Elements;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Toby\Eloquent\Models\Vacation;
|
||||
|
||||
class AbsencesAttachment extends ListAttachment
|
||||
{
|
||||
public function __construct(Collection $absences)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this
|
||||
->setTitle("Nieobecności :palm_tree:")
|
||||
->setColor("#eab308")
|
||||
->setItems($absences->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name))
|
||||
->setEmptyText("Wszyscy dzisiaj pracują :muscle:");
|
||||
}
|
||||
}
|
||||
12
app/Infrastructure/Slack/Elements/Attachment.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Infrastructure\Slack\Elements;
|
||||
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Spatie\SlashCommand\Attachment as BaseAttachment;
|
||||
|
||||
class Attachment extends BaseAttachment implements Arrayable
|
||||
{
|
||||
}
|
||||
22
app/Infrastructure/Slack/Elements/BirthdaysAttachment.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Infrastructure\Slack\Elements;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Toby\Eloquent\Models\User;
|
||||
|
||||
class BirthdaysAttachment extends ListAttachment
|
||||
{
|
||||
public function __construct(Collection $birthdays)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this
|
||||
->setTitle("Urodziny :birthday:")
|
||||
->setColor("#3c5f97")
|
||||
->setItems($birthdays->map(fn(User $user): string => $user->profile->full_name))
|
||||
->setEmptyText("Dzisiaj nikt nie ma urodzin :cry:");
|
||||
}
|
||||
}
|
||||
21
app/Infrastructure/Slack/Elements/KeysAttachment.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Infrastructure\Slack\Elements;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Toby\Eloquent\Models\Key;
|
||||
|
||||
class KeysAttachment extends ListAttachment
|
||||
{
|
||||
public function __construct(Collection $keys)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this
|
||||
->setColor("#3c5f97")
|
||||
->setItems($keys->map(fn(Key $key): string => "Klucz nr {$key->id} - <@{$key->user->profile->slack_id}>"))
|
||||
->setEmptyText("Nie ma żadnych kluczy w tobym");
|
||||
}
|
||||
}
|
||||
36
app/Infrastructure/Slack/Elements/ListAttachment.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Infrastructure\Slack\Elements;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class ListAttachment extends Attachment
|
||||
{
|
||||
protected Collection $items;
|
||||
protected string $emptyText = "";
|
||||
|
||||
public function setItems(Collection $items): static
|
||||
{
|
||||
$this->items = $items;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setEmptyText(string $emptyText): static
|
||||
{
|
||||
$this->emptyText = $emptyText;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
$fields = parent::toArray();
|
||||
|
||||
return array_merge($fields, [
|
||||
"text" => $this->items->isNotEmpty() ? $this->items->implode("\n") : $this->emptyText,
|
||||
]);
|
||||
}
|
||||
}
|
||||
22
app/Infrastructure/Slack/Elements/RemotesAttachment.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Infrastructure\Slack\Elements;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Toby\Eloquent\Models\Vacation;
|
||||
|
||||
class RemotesAttachment extends ListAttachment
|
||||
{
|
||||
public function __construct(Collection $remoteDays)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this
|
||||
->setTitle("Praca zdalna :house_with_garden:")
|
||||
->setColor("#527aba")
|
||||
->setItems($remoteDays->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name))
|
||||
->setEmptyText("Wszyscy dzisiaj są w biurze :boom:");
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack\Exceptions;
|
||||
namespace Toby\Infrastructure\Slack\Exceptions;
|
||||
|
||||
use Spatie\SlashCommand\Exceptions\SlackSlashCommandException;
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack\Handlers;
|
||||
namespace Toby\Infrastructure\Slack\Handlers;
|
||||
|
||||
use Spatie\SlashCommand\Attachment;
|
||||
use Spatie\SlashCommand\Handlers\BaseHandler;
|
||||
use Spatie\SlashCommand\Request;
|
||||
use Spatie\SlashCommand\Response;
|
||||
use Toby\Domain\Slack\Traits\ListsHandlers;
|
||||
use Toby\Infrastructure\Slack\Elements\Attachment;
|
||||
use Toby\Infrastructure\Slack\Traits\ListsHandlers;
|
||||
|
||||
class CatchAll extends BaseHandler
|
||||
{
|
||||
@@ -24,7 +24,7 @@ class CatchAll extends BaseHandler
|
||||
$handlers = $this->findAvailableHandlers();
|
||||
$attachmentFields = $this->mapHandlersToAttachments($handlers);
|
||||
|
||||
return $this->respondToSlack(":x: Nie rozpoznaję tej komendy. Lista wszystkich komend:")
|
||||
return $this->respondToSlack(":x: Nie rozpoznaję polecenia. Lista wszystkich poleceń:")
|
||||
->withAttachment(
|
||||
Attachment::create()
|
||||
->setColor("danger")
|
||||
36
app/Infrastructure/Slack/Handlers/DailySummary.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Infrastructure\Slack\Handlers;
|
||||
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Spatie\SlashCommand\Request;
|
||||
use Spatie\SlashCommand\Response;
|
||||
use Toby\Domain\DailySummaryRetriever;
|
||||
use Toby\Infrastructure\Slack\Elements\AbsencesAttachment;
|
||||
use Toby\Infrastructure\Slack\Elements\BirthdaysAttachment;
|
||||
use Toby\Infrastructure\Slack\Elements\RemotesAttachment;
|
||||
|
||||
class DailySummary extends SignatureHandler
|
||||
{
|
||||
protected $signature = "toby dzisiaj";
|
||||
protected $description = "Codzienne podsumowanie";
|
||||
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$dailySummaryRetriever = app()->make(DailySummaryRetriever::class);
|
||||
|
||||
$now = Carbon::today();
|
||||
|
||||
$attachments = new Collection([
|
||||
new AbsencesAttachment($dailySummaryRetriever->getAbsences($now)),
|
||||
new RemotesAttachment($dailySummaryRetriever->getRemoteDays($now)),
|
||||
new BirthdaysAttachment($dailySummaryRetriever->getBirthdays($now)),
|
||||
]);
|
||||
|
||||
return $this->respondToSlack("Podsumowanie dla dnia {$now->toDisplayString()}")
|
||||
->withAttachments($attachments->all());
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,16 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack\Handlers;
|
||||
namespace Toby\Infrastructure\Slack\Handlers;
|
||||
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Spatie\SlashCommand\Request;
|
||||
use Spatie\SlashCommand\Response;
|
||||
use Toby\Domain\Notifications\KeyHasBeenGivenNotification;
|
||||
use Toby\Domain\Slack\Exceptions\UserNotFoundException;
|
||||
use Toby\Domain\Slack\Rules\SlackUserExistsRule;
|
||||
use Toby\Domain\Slack\Traits\FindsUserBySlackId;
|
||||
use Toby\Eloquent\Models\Key;
|
||||
use Toby\Infrastructure\Slack\Exceptions\UserNotFoundException;
|
||||
use Toby\Infrastructure\Slack\Rules\SlackUserExistsRule;
|
||||
use Toby\Infrastructure\Slack\Traits\FindsUserBySlackId;
|
||||
|
||||
class GiveKeysTo extends SignatureHandler
|
||||
{
|
||||
@@ -2,19 +2,19 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack\Handlers;
|
||||
namespace Toby\Infrastructure\Slack\Handlers;
|
||||
|
||||
use Spatie\SlashCommand\Attachment;
|
||||
use Spatie\SlashCommand\Request;
|
||||
use Spatie\SlashCommand\Response;
|
||||
use Toby\Domain\Slack\Traits\ListsHandlers;
|
||||
use Toby\Infrastructure\Slack\Elements\Attachment;
|
||||
use Toby\Infrastructure\Slack\Traits\ListsHandlers;
|
||||
|
||||
class Help extends SignatureHandler
|
||||
{
|
||||
use ListsHandlers;
|
||||
|
||||
protected $signature = "toby pomoc";
|
||||
protected $description = "Wyświetl wszystkie dostępne komendy";
|
||||
protected $description = "Wyświetl wszystkie dostępne polecenia";
|
||||
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
@@ -22,7 +22,7 @@ class Help extends SignatureHandler
|
||||
|
||||
$attachmentFields = $this->mapHandlersToAttachments($handlers);
|
||||
|
||||
return $this->respondToSlack("Dostępne komendy:")
|
||||
return $this->respondToSlack("Dostępne polecenia:")
|
||||
->withAttachment(
|
||||
Attachment::create()
|
||||
->setColor("good")
|
||||
@@ -2,16 +2,16 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack\Handlers;
|
||||
namespace Toby\Infrastructure\Slack\Handlers;
|
||||
|
||||
use Illuminate\Support\Carbon;
|
||||
use Spatie\SlashCommand\Request;
|
||||
use Spatie\SlashCommand\Response;
|
||||
use Toby\Domain\Actions\VacationRequest\CreateAction;
|
||||
use Toby\Domain\Enums\VacationType;
|
||||
use Toby\Domain\Slack\Traits\FindsUserBySlackId;
|
||||
use Toby\Eloquent\Models\User;
|
||||
use Toby\Eloquent\Models\YearPeriod;
|
||||
use Toby\Infrastructure\Slack\Traits\FindsUserBySlackId;
|
||||
|
||||
class HomeOffice extends SignatureHandler
|
||||
{
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack\Handlers;
|
||||
namespace Toby\Infrastructure\Slack\Handlers;
|
||||
|
||||
use Spatie\SlashCommand\Attachment;
|
||||
use Spatie\SlashCommand\Request;
|
||||
use Spatie\SlashCommand\Response;
|
||||
use Toby\Eloquent\Models\Key;
|
||||
use Toby\Infrastructure\Slack\Elements\KeysAttachment;
|
||||
|
||||
class KeyList extends SignatureHandler
|
||||
{
|
||||
@@ -18,14 +18,9 @@ class KeyList extends SignatureHandler
|
||||
{
|
||||
$keys = Key::query()
|
||||
->orderBy("id")
|
||||
->get()
|
||||
->map(fn(Key $key) => "Klucz nr {$key->id} - <@{$key->user->profile->slack_id}>");
|
||||
->get();
|
||||
|
||||
return $this->respondToSlack("Lista kluczy :key:")
|
||||
->withAttachment(
|
||||
Attachment::create()
|
||||
->setColor("#3c5f97")
|
||||
->setText($keys->isNotEmpty() ? $keys->implode("\n") : "Nie ma żadnych kluczy w tobym"),
|
||||
);
|
||||
->withAttachment(new KeysAttachment($keys));
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack\Handlers;
|
||||
namespace Toby\Infrastructure\Slack\Handlers;
|
||||
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Spatie\SlashCommand\Handlers\SignatureHandler as BaseSignatureHandler;
|
||||
@@ -2,16 +2,16 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack\Handlers;
|
||||
namespace Toby\Infrastructure\Slack\Handlers;
|
||||
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Spatie\SlashCommand\Request;
|
||||
use Spatie\SlashCommand\Response;
|
||||
use Toby\Domain\Notifications\KeyHasBeenTakenNotification;
|
||||
use Toby\Domain\Slack\Exceptions\UserNotFoundException;
|
||||
use Toby\Domain\Slack\Rules\SlackUserExistsRule;
|
||||
use Toby\Domain\Slack\Traits\FindsUserBySlackId;
|
||||
use Toby\Eloquent\Models\Key;
|
||||
use Toby\Infrastructure\Slack\Exceptions\UserNotFoundException;
|
||||
use Toby\Infrastructure\Slack\Rules\SlackUserExistsRule;
|
||||
use Toby\Infrastructure\Slack\Traits\FindsUserBySlackId;
|
||||
|
||||
class TakeKeysFrom extends SignatureHandler
|
||||
{
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack\Rules;
|
||||
namespace Toby\Infrastructure\Slack\Rules;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack\Traits;
|
||||
namespace Toby\Infrastructure\Slack\Traits;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Toby\Domain\Slack\Exceptions\UserNotFoundException;
|
||||
use Toby\Eloquent\Models\User;
|
||||
use Toby\Infrastructure\Slack\Exceptions\UserNotFoundException;
|
||||
|
||||
trait FindsUserBySlackId
|
||||
{
|
||||
@@ -2,11 +2,12 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Slack\Traits;
|
||||
namespace Toby\Infrastructure\Slack\Traits;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use Spatie\SlashCommand\AttachmentField;
|
||||
use Spatie\SlashCommand\Handlers\BaseHandler;
|
||||
use Spatie\SlashCommand\Handlers\SignatureHandler;
|
||||
use Spatie\SlashCommand\Handlers\SignatureParts;
|
||||
use Spatie\SlashCommand\HandlesSlashCommand;
|
||||
@@ -16,8 +17,8 @@ trait ListsHandlers
|
||||
protected function findAvailableHandlers(): Collection
|
||||
{
|
||||
return collect(config("laravel-slack-slash-command.handlers"))
|
||||
->map(fn(string $handlerClassName) => new $handlerClassName($this->request))
|
||||
->filter(fn(HandlesSlashCommand $handler) => $handler instanceof SignatureHandler)
|
||||
->map(fn(string $handlerClassName): BaseHandler => new $handlerClassName($this->request))
|
||||
->filter(fn(HandlesSlashCommand $handler): bool => $handler instanceof SignatureHandler)
|
||||
->filter(function (SignatureHandler $handler) {
|
||||
$signatureParts = new SignatureParts($handler->getSignature());
|
||||
|
||||
@@ -29,13 +30,13 @@ trait ListsHandlers
|
||||
{
|
||||
return $handlers
|
||||
->sort(
|
||||
fn(SignatureHandler $handlerA, SignatureHandler $handlerB) => strcmp(
|
||||
fn(SignatureHandler $handlerA, SignatureHandler $handlerB): int => strcmp(
|
||||
$handlerA->getFullCommand(),
|
||||
$handlerB->getFullCommand(),
|
||||
),
|
||||
)
|
||||
->map(
|
||||
fn(SignatureHandler $handler) => AttachmentField::create(
|
||||
fn(SignatureHandler $handler): AttachmentField => AttachmentField::create(
|
||||
$handler->getDescription(),
|
||||
"`/{$handler->getSignature()}`",
|
||||
),
|
||||
@@ -2,17 +2,16 @@
|
||||
|
||||
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\TakeKeysFrom;
|
||||
use Toby\Infrastructure\Slack\Handlers\CatchAll;
|
||||
use Toby\Infrastructure\Slack\Handlers\DailySummary;
|
||||
use Toby\Infrastructure\Slack\Handlers\GiveKeysTo;
|
||||
use Toby\Infrastructure\Slack\Handlers\Help;
|
||||
use Toby\Infrastructure\Slack\Handlers\HomeOffice;
|
||||
use Toby\Infrastructure\Slack\Handlers\KeyList;
|
||||
use Toby\Infrastructure\Slack\Handlers\TakeKeysFrom;
|
||||
|
||||
return [
|
||||
"signing_secret" => env("SLACK_SIGNING_SECRET"),
|
||||
"verify_with_signing" => true,
|
||||
"handlers" => [
|
||||
TakeKeysFrom::class,
|
||||
GiveKeysTo::class,
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Toby\Domain\Slack\Controller as SlackController;
|
||||
use Toby\Infrastructure\Http\Controllers\Api\CalculateUserUnavailableDaysController;
|
||||
use Toby\Infrastructure\Http\Controllers\Api\CalculateUserVacationStatsController;
|
||||
use Toby\Infrastructure\Http\Controllers\Api\CalculateVacationDaysController;
|
||||
use Toby\Infrastructure\Http\Controllers\Api\GetAvailableVacationTypesController;
|
||||
use Toby\Infrastructure\Slack\Controller as SlackController;
|
||||
|
||||
Route::post("slack", [SlackController::class, "getResponse"]);
|
||||
|
||||
|
||||