#116 - integration with slack (#129)

* wip

* wip

* wip

* wip

* fix

* wip

* wip

* fix

* fix

* cs fix

* #116 - fix

* #116 - changed home-office icon

* Apply suggestions from code review

Co-authored-by: Krzysztof Rewak <krzysztof.rewak@gmail.com>

* #116 - cr fix

* #116 - cs fix

* #116 - cs fix

* Apply suggestions from code review

Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>

* #5 - bump codestyle

Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl>
Co-authored-by: Krzysztof Rewak <krzysztof.rewak@gmail.com>
Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>
This commit is contained in:
Adrian Hopek
2022-04-27 09:57:13 +02:00
committed by GitHub
parent d60dc75f99
commit c69866bb52
78 changed files with 1597 additions and 243 deletions

View File

@@ -21,7 +21,6 @@ class Holiday extends Model
use HasFactory;
protected $guarded = [];
protected $casts = [
"date" => "date",
];

View File

@@ -8,14 +8,17 @@ use Database\Factories\KeyFactory;
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;
protected $guarded = [];
@@ -24,6 +27,11 @@ class Key extends Model
return $this->belongsTo(User::class);
}
public function routeNotificationForSlack(): string
{
return config("services.slack.default_channel");
}
protected static function newFactory(): KeyFactory
{
return KeyFactory::new();

View File

@@ -19,6 +19,7 @@ use Toby\Eloquent\Helpers\ColorGenerator;
* @property string $position
* @property EmploymentForm $employment_form
* @property Carbon $employment_date
* @property Carbon $birthday
*/
class Profile extends Model
{
@@ -26,12 +27,11 @@ class Profile extends Model
use HasAvatar;
protected $primaryKey = "user_id";
protected $guarded = [];
protected $casts = [
"employment_form" => EmploymentForm::class,
"employment_date" => "date",
"birthday" => "date",
];
public function user(): BelongsTo

View File

@@ -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,25 +27,22 @@ 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;
use SoftDeletes;
protected $guarded = [];
protected $casts = [
"role" => Role::class,
"last_active_at" => "datetime",
"employment_form" => EmploymentForm::class,
"employment_date" => "date",
];
protected $hidden = [
"remember_token",
];
protected $with = [
"profile",
];
@@ -102,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}%"),
);
@@ -125,6 +123,11 @@ class User extends Authenticatable
);
}
public function routeNotificationForSlack()
{
return $this->profile->slack_id;
}
protected static function newFactory(): UserFactory
{
return UserFactory::new();

View File

@@ -41,7 +41,6 @@ class VacationRequest extends Model
use HasStates;
protected $guarded = [];
protected $casts = [
"type" => VacationType::class,
"state" => VacationRequestState::class,

View File

@@ -22,7 +22,6 @@ class VacationRequestActivity extends Model
use HasFactory;
protected $guarded = [];
protected $casts = [
"from" => VacationRequestState::class,
"to" => VacationRequestState::class,