Neues Modul Interne Stellenausschreibungen (0.28.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 6m18s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m1s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 5m33s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 5m8s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 6m42s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m37s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m43s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m38s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m10s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 6m18s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m1s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 5m33s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 5m8s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 6m42s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m37s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m43s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m38s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m10s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b322b97f32
commit
993d49c99c
146 changed files with 1981 additions and 305 deletions
102
plugins-core/stellen/src/Models/JobPosting.php
Normal file
102
plugins-core/stellen/src/Models/JobPosting.php
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Stellen\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Eine interne Stellenausschreibung. Sichtbar ab „published_at“ bis einschließlich zur Frist.
|
||||
*/
|
||||
#[Fillable(['title', 'department', 'location', 'employment', 'hours', 'contract', 'contract_note', 'pay_grade', 'start', 'deadline',
|
||||
'description', 'pdf_path', 'pdf_name', 'apply_mode', 'apply_url', 'contact_id', 'notify_email', 'published_at', 'created_by', 'updated_by'])]
|
||||
class JobPosting extends Model
|
||||
{
|
||||
public const DISK = 'local';
|
||||
|
||||
public const EMPLOYMENT = ['full' => 'Vollzeit', 'part' => 'Teilzeit', 'flex' => 'Voll- oder Teilzeit', 'mini' => 'Minijob', 'training' => 'Ausbildung / Studium', 'other' => 'Sonstiges'];
|
||||
|
||||
public const CONTRACT = ['permanent' => 'Unbefristet', 'fixed' => 'Befristet'];
|
||||
|
||||
public const APPLY_MODES = ['online' => 'Online im Portal', 'contact' => 'Über die Ansprechperson', 'link' => 'Über einen Link'];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::deleting(function (JobPosting $posting) {
|
||||
if ($posting->pdf_path) {
|
||||
Storage::disk(self::DISK)->delete($posting->pdf_path);
|
||||
}
|
||||
|
||||
$posting->applications()->get()->each->delete();
|
||||
});
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['deadline' => 'date', 'published_at' => 'datetime', 'announced_at' => 'datetime'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Offene Stellen: veröffentlicht und Frist nicht abgelaufen.
|
||||
*
|
||||
* @param Builder<JobPosting> $query
|
||||
*/
|
||||
public function scopeOpen(Builder $query): void
|
||||
{
|
||||
$query->whereNotNull('published_at')->where('published_at', '<=', now())
|
||||
->where(fn (Builder $q) => $q->whereNull('deadline')->orWhereDate('deadline', '>=', today()));
|
||||
}
|
||||
|
||||
public function isOpen(): bool
|
||||
{
|
||||
return $this->published_at !== null && $this->published_at->isPast() && ($this->deadline === null || ! $this->deadline->isBefore(today()));
|
||||
}
|
||||
|
||||
public function status(): string
|
||||
{
|
||||
return match (true) {
|
||||
$this->published_at === null => 'draft',
|
||||
$this->published_at->isFuture() => 'scheduled',
|
||||
$this->deadline !== null && $this->deadline->isBefore(today()) => 'expired',
|
||||
default => 'open',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
public function contact(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'contact_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<JobApplication, $this>
|
||||
*/
|
||||
public function applications(): HasMany
|
||||
{
|
||||
return $this->hasMany(JobApplication::class, 'posting_id');
|
||||
}
|
||||
|
||||
/** Wer die Bewerbungen dieser Stelle sehen darf */
|
||||
public function canSeeApplications(?User $user): bool
|
||||
{
|
||||
return $user !== null && ($user->can('jobs.applications') || ($this->contact_id !== null && $this->contact_id === $user->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Kurzfassung der Eckdaten, z. B. „Teilzeit (30 Std./Woche) · befristet bis 31.12.2027“.
|
||||
*/
|
||||
public function summary(): string
|
||||
{
|
||||
return collect([
|
||||
self::EMPLOYMENT[$this->employment] ?? null,
|
||||
$this->hours ? '('.$this->hours.')' : null,
|
||||
])->filter()->implode(' ').($this->contract === 'fixed' ? ' · befristet'.($this->contract_note ? ' '.$this->contract_note : '') : '');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue