Compare commits

...
4 Commits
Author SHA1 Message Date
DigitalInfinity 96ae73025a fehler bei edit todo wegen SetReminderAction 2026-07-03 20:15:57 +00:00
DigitalInfinity f67f00a3c7 schedule script 2026-07-02 20:23:38 +00:00
DigitalInfinity b532c51c32 added docker-compose file for production 2026-07-02 20:22:24 +00:00
DigitalInfinity ec6d7e2a80 reminder for todos 2026-07-02 19:34:12 +00:00
15 changed files with 343 additions and 25 deletions

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
.git
.gitattributes
.github
.env
.env.*
auth.json
node_modules
vendor
public/build
public/hot
public/storage
storage/*.key
storage/app/*
storage/framework/cache/*
storage/framework/sessions/*
storage/framework/testing/*
storage/framework/views/*
storage/logs/*
storage/pail
!storage/app/.gitignore
!storage/framework/**/.gitignore
!storage/logs/.gitignore
database/database.sqlite
tests
.phpunit.cache
.phpunit.result.cache
.devcontainer
.claude
.idea
.vscode
.fleet
.zed
docker-compose.yml
Dockerfile
+54
View File
@@ -0,0 +1,54 @@
# syntax=docker/dockerfile:1.7
ARG PHP_VERSION=8.5
# --- frontend assets -------------------------------------------------------
FROM node:22-alpine AS frontend
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY vite.config.js ./
COPY resources ./resources
RUN npm run build
# --- application -------------------------------------------------------
FROM php:${PHP_VERSION}-apache AS app
RUN apt-get update && apt-get install -y --no-install-recommends \
libsqlite3-dev \
libicu-dev \
libzip-dev \
unzip \
git \
curl \
&& docker-php-ext-install \
pdo_sqlite \
intl \
zip \
bcmath \
pcntl \
opcache \
&& a2enmod rewrite \
&& rm -rf /var/lib/apt/lists/*
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
COPY docker/apache/000-default.conf /etc/apache2/sites-available/000-default.conf
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
WORKDIR /var/www/html
COPY . .
COPY --from=frontend /app/public/build ./public/build
# auth.json holds the Filament composer repository credentials; it's
# gitignored and must never end up baked into an image layer, so it's
# supplied as a BuildKit secret and mounted only for this RUN step.
RUN --mount=type=secret,id=composer_auth,target=/var/www/html/auth.json \
composer install --no-dev --no-interaction --no-progress --optimize-autoloader
RUN mkdir -p storage/app storage/framework/cache storage/framework/sessions storage/framework/views storage/logs bootstrap/cache \
&& chown -R www-data:www-data storage bootstrap/cache
ENTRYPOINT ["entrypoint.sh"]
CMD ["apache2-foreground"]
@@ -0,0 +1,37 @@
<?php
namespace App\Console\Commands;
use App\Mail\TodoMail;
use App\Models\Todo;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
#[Signature('app:send-todo-follow-up-reminders')]
#[Description('Send reminder emails for todos whose follow-up date has been reached')]
class SendTodoFollowUpReminders extends Command
{
/**
* Execute the console command.
*/
public function handle(): void
{
$todos = Todo::query()
->whereNull('done_date')
->whereNull('follow_up_notified_at')
->whereNotNull('follow_up')
->whereDate('follow_up', '<=', today())
->get();
foreach ($todos as $todo) {
foreach ($todo->getassignetusers() as $user) {
Mail::to($user)->send(new TodoMail($todo, 'Todo Wiedervorlage', 'Die Wiedervorlage für folgende Todo ist erreicht:'));
}
$todo->follow_up_notified_at = now();
$todo->saveQuietly();
}
}
}
@@ -0,0 +1,38 @@
<?php
namespace App\Filament\Actions;
use Filament\Actions\Action;
use Filament\Actions\ActionGroup;
use Filament\Support\Icons\Heroicon;
use Illuminate\Database\Eloquent\Model;
class SetReminderAction extends ActionGroup
{
protected function setUp(): void
{
parent::setUp();
$this->label('Erinnerung')
->tooltip('Wiedervorlage setzen')
->icon(Heroicon::BellSnooze)
->iconButton()
->visible(function (Model $record) {
return $record->is_owner_or_assigned();
})
->actions([
Action::make('reminderIn1Day')
->label('in 1 Tag')
->action(fn (Model $record) => $record->update(['follow_up' => now()->addDay()])),
Action::make('reminderIn3Days')
->label('in 3 Tagen')
->action(fn (Model $record) => $record->update(['follow_up' => now()->addDays(3)])),
Action::make('reminderIn1Week')
->label('in 1 Woche')
->action(fn (Model $record) => $record->update(['follow_up' => now()->addWeek()])),
Action::make('reminderIn1Month')
->label('in 1 Monat')
->action(fn (Model $record) => $record->update(['follow_up' => now()->addMonth()])),
]);
}
}
@@ -4,6 +4,7 @@ namespace App\Filament\Resources\Todos\Pages;
use App\Filament\Actions\DoneTodoAction;
use App\Filament\Actions\ReopenTodoAction;
use App\Filament\Actions\SetReminderAction;
use App\Filament\Resources\Todos\TodoResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
@@ -18,6 +19,7 @@ class EditTodo extends EditRecord
return [
DoneTodoAction::make('done'),
ReopenTodoAction::make('reopen'),
SetReminderAction::make([])->record(fn () => $this->getRecord()),
DeleteAction::make()->iconButton()->icon(Heroicon::Trash),
];
}
@@ -39,7 +39,7 @@ class TodoForm
Toggle::make('review')->label('Review')->hint('Todo geht nach Erledigung noch mal zum Ersteller'),
]),
// DatePicker::make('follow_up')->label('Wiedervorlage/Erinnerung'),
DatePicker::make('follow_up')->label('Wiedervorlage/Erinnerung')->hiddenOn(['create']),
DatePicker::make('done_date')->label('Erledigt am')->hiddenOn(['create']),
]);
}
@@ -4,14 +4,13 @@ namespace App\Filament\Resources\Todos\Tables;
use App\Filament\Actions\DoneTodoAction;
use App\Filament\Actions\ReopenTodoAction;
use App\Filament\Actions\SetReminderAction;
use App\Models\Group;
use App\Models\User;
use Filament\Actions\Action;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\Filter;
@@ -52,10 +51,10 @@ class TodosTable
->label('Erledigt am')
->date()
->sortable(),
// TextColumn::make('follow_up')
// ->label('Wiedervorlage')
// ->date()
// ->sortable(),
TextColumn::make('follow_up')
->label('Wiedervorlage')
->date()
->sortable(),
IconColumn::make('review')
->label('Review')
->boolean(),
@@ -66,6 +65,7 @@ class TodosTable
->label('nicht erledigt')
->query(function (Builder $query) {
$query->whereNull('done_date');
return $query;
}),
Filter::make('mine')->label('von mir oder für mich')
@@ -76,8 +76,24 @@ class TodosTable
->orWhere('user_id', filament()->auth()->user()->id)
->orWhere('todoable_type', User::class)->where('todoable_id', filament()->auth()->user()->id)
->orwhere('todoable_type', Group::class)->whereIn('todoable_id', User::find(filament()->auth()->user()->id)->groups()->get()->pluck('id'));
return $query;
});
return $query;
}),
Filter::make('keineZukuenftigeWiedervorlage')
->label('ohne zukünftige Wiedervorlage')
->default()
->query(function (Builder $query) {
$query->where(function (Builder $query) {
$query
->whereNull('follow_up')
->orWhereDate('follow_up', '<=', today());
return $query;
});
return $query;
}),
@@ -85,6 +101,7 @@ class TodosTable
->recordActions([
DoneTodoAction::make('done'),
ReopenTodoAction::make('reopen'),
SetReminderAction::make([]),
EditAction::make()->iconButton(),
DeleteAction::make()->iconButton()
->visible(function (Model $record) {
+22 -9
View File
@@ -9,7 +9,7 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphTo;
#[Fillable('name', 'content', 'user_id', 'todoable_type', 'todoable_id', 'due_date', 'done_date', 'follow_up', 'review')]
#[Fillable('name', 'content', 'user_id', 'todoable_type', 'todoable_id', 'due_date', 'done_date', 'follow_up', 'follow_up_notified_at', 'review')]
#[ObservedBy([TodoObserver::class])]
class Todo extends Model
{
@@ -23,15 +23,28 @@ class Todo extends Model
return $this->belongsTo(User::class);
}
public function is_owner_or_assigned() {
if(filament()->auth()->user()->id == $this->user_id) return true;
if($this->todoable_type == Group::class && in_array(filament()->auth()->user()->id, $this->todoable()->first()->users()->get()->pluck('id')->toArray())) return true;
if($this->todoable_type == User::class && $this->todoable()->first()->id == filament()->auth()->user()->id) return true;
else return false;
public function is_owner_or_assigned()
{
if (filament()->auth()->user()->id == $this->user_id) {
return true;
}
if ($this->todoable_type == Group::class && in_array(filament()->auth()->user()->id, $this->todoable()->first()->users()->get()->pluck('id')->toArray())) {
return true;
}
if ($this->todoable_type == User::class && $this->todoable()->first()->id == filament()->auth()->user()->id) {
return true;
} else {
return false;
}
}
public function getassignetusers() {
if($this->todoable_type == Group::class) return $this->todoable()->first()->users()->get();
if($this->todoable_type == User::class) return [$this->todoable()->first()];
public function getassignetusers()
{
if ($this->todoable_type == Group::class) {
return $this->todoable()->first()->users()->get();
}
if ($this->todoable_type == User::class) {
return [$this->todoable()->first()];
}
}
}
+14 -9
View File
@@ -2,16 +2,10 @@
namespace App\Observers;
use App\Mail\TodoAssigned;
use App\Mail\TodoCreated;
use App\Mail\TodoMail;
use App\Mail\TodoNeedsReview;
use App\Mail\TodoReopened;
use App\Models\Group;
use App\Models\Todo;
use App\Models\User;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Str;
class TodoObserver
{
@@ -20,12 +14,13 @@ class TodoObserver
*/
public function created(Todo $todo): void
{
if($todo->todoable_type == null) return;
if ($todo->todoable_type == null) {
return;
}
// if($todo->todoable_type == User::class && $todo->user_id == $todo->todoable_id) return;
if ($todo->todoable_type == User::class) {
Mail::to(User::find($todo->todoable()->first()))->send(new TodoMail($todo, 'Neue Todo', 'Es gibt eine neue Todo für dich:'));
}
else {
} else {
$users = $todo->todoable()->first()->users()->get();
foreach ($users as $user) {
Mail::to($user)->send(new TodoMail($todo, 'Neue Todo', 'Es gibt eine neue Todo für dich:'));
@@ -33,6 +28,16 @@ class TodoObserver
}
}
/**
* Handle the Todo "updating" event.
*/
public function updating(Todo $todo): void
{
if ($todo->isDirty('follow_up')) {
$todo->follow_up_notified_at = null;
}
}
/**
* Handle the Todo "updated" event.
*/
+4
View File
@@ -1,5 +1,6 @@
<?php
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
@@ -15,4 +16,7 @@ return Application::configure(basePath: dirname(__DIR__))
})
->withExceptions(function (Exceptions $exceptions): void {
//
})
->withSchedule(function (Schedule $schedule): void {
$schedule->command('app:send-todo-follow-up-reminders')->dailyAt('07:00');
})->create();
@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('todos', function (Blueprint $table) {
$table->timestamp('follow_up_notified_at')->nullable()->after('follow_up');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('todos', function (Blueprint $table) {
$table->dropColumn('follow_up_notified_at');
});
}
};
+41
View File
@@ -0,0 +1,41 @@
x-app: &app
image: z-lab-cockpit:latest
env_file: .env
# environment:
# DB_CONNECTION: sqlite
# DB_DATABASE: /var/www/html/storage/app/database.sqlite
volumes:
- ./storage:/var/www/html/storage
depends_on:
app:
condition: service_healthy
restart: unless-stopped
services:
app:
<<: *app
build:
context: .
secrets:
- composer_auth
depends_on: []
ports:
- "8000:80"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/up"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
queue:
<<: *app
command: ["php", "artisan", "queue:work", "--tries=3", "--backoff=10"]
scheduler:
<<: *app
command: ["php", "artisan", "schedule:work"]
secrets:
composer_auth:
file: ./auth.json
+12
View File
@@ -0,0 +1,12 @@
<VirtualHost *:80>
DocumentRoot /var/www/html/public
<Directory /var/www/html/public>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
+23
View File
@@ -0,0 +1,23 @@
#!/bin/sh
set -e
cd /var/www/html
mkdir -p storage/app storage/framework/cache storage/framework/sessions storage/framework/views storage/logs bootstrap/cache
chown -R www-data:www-data storage bootstrap/cache
if [ -n "$DB_DATABASE" ] && [ "$DB_CONNECTION" = "sqlite" ]; then
mkdir -p "$(dirname "$DB_DATABASE")"
touch -a "$DB_DATABASE"
chown www-data:www-data "$DB_DATABASE"
fi
# Only the web process runs bootstrap steps, so the queue/scheduler
# containers (which override CMD) don't race each other on migrations.
if [ "$1" = "apache2-foreground" ]; then
php artisan config:clear
php artisan migrate --force
php artisan storage:link || true
fi
exec "$@"
+2
View File
@@ -0,0 +1,2 @@
#//bin/sh
/usr/bin/php artisan schedule:work