no message

This commit is contained in:
StudioTem committed 2025-03-19 10:07:33 +01:00
1 parent e1712c8fcd
commit c77b19d229
8 files changed
+334 -30

No files matched your search

+15 -16
View File
@@ -12,6 +12,12 @@ class MasterTask extends Model
public $timestamps = true;
public $guarded = ['id'];
public static function generateMasterTaskColor()
{
// return random value from array
return collect(['#E9FFE5', '#F6ECD3', '#FDE1FF', '#FFC9C9', '#DADEF8', '#EDFFFE', '#FFDED7'])->random();
}
public function subtasks()
{
return $this->hasMany(SubTask::class);
@@ -22,11 +28,6 @@ class MasterTask extends Model
return $this->belongsTo(Project::class);
}
public function attachments()
{
return $this->hasMany(Attachment::class);
}
public function team()
{
return $this->belongsTo(Team::class);
@@ -38,12 +39,12 @@ class MasterTask extends Model
$users = $this->subtasks->pluck('user')->unique();
// ak nie je uvedeny ziaden team, tak sa vratia vsetci useri
if (!$this->team){
if ( ! $this->team) {
return $users;
}
return $users->filter(function ($user) {
return !in_array($this->team->id, $user->teams->pluck('id')->unique()->toArray());
return ! in_array($this->team->id, $user->teams->pluck('id')->unique()->toArray());
});
}
@@ -53,15 +54,9 @@ class MasterTask extends Model
return $this->subtasks->pluck('user')->unique();
}
public static function generateMasterTaskColor()
{
// return random value from array
return collect(['#E9FFE5', '#F6ECD3', '#FDE1FF', '#FFC9C9', '#DADEF8', '#EDFFFE', '#FFDED7'])->random();
}
public function deleteAttachments()
{
foreach ( $this->attachments as $attachment ) {
foreach ($this->attachments as $attachment) {
$attachment->deleteFromS3();
}
@@ -70,6 +65,11 @@ class MasterTask extends Model
return true;
}
public function attachments()
{
return $this->hasMany(Attachment::class);
}
public function recalculateEstimatedTime()
{
$this->estimated_time = $this->subtasks->sum('estimated_time');
@@ -80,12 +80,11 @@ class MasterTask extends Model
{
$trackedTime = 0.0;
foreach ( $this->subtasks as $subtask ) {
foreach ($this->subtasks as $subtask) {
$trackedTime += $subtask->timesheets->sum('time');
}
$this->tracked_time = $trackedTime;
$this->save();
}
}