This commit is contained in:
salam committed 2026-06-23 08:31:15 +02:00
1 parent 23bed33cf3
commit 1294243ac0
2 files changed
+4 -5

No files matched your search

@@ -28,13 +28,12 @@ class ProjektesTable
->columns([
TextColumn::make('id'),
ToggleColumn::make('meine')
->state(fn($record) => ProjektUser::where('user_id', auth()->user()->id)->where('projekte_id', $record->id)->count())
->beforeStateUpdated(function ($record, $state) {
if($state){
ProjektUser::where('user_id', auth()->user()->id)->where('projekte_id', $record->id)->delete();
return;
}else{
ProjektUser::create(['user_id' => auth()->user()->id, 'projekte_id' => $record->id]);
return;
}else{
ProjektUser::where('user_id', auth()->user()->id)->where('projekte_id', $record->id)->delete();
}
}),
TextColumn::make('interner_name')
+1 -1
View File
@@ -58,7 +58,7 @@ class Projekte extends Model
];
}
public function meine()
public function projekt_users()
{
return $this->belongsToMany(Projekte::class, 'projekt_users', 'projekte_id', 'user_id');
}