mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
tasks endpoint update
This commit is contained in:
1 parent
ce454ffd0e
commit
17ed7616ee
6 files changed
+183
-11
No files matched your search
@@ -36,6 +36,37 @@ class SubTask extends Model
|
||||
{
|
||||
return $this->hasMany(Attachment::class);
|
||||
}
|
||||
|
||||
// syncnutie vykazu. ak array obsahuje NULL id, tak ho vytvori, ak obsahuje ID, tak ho upravi. ak sa v array nenachadza, tak ho zmaze z DB
|
||||
public function syncTimesheets(Array $timesheets)
|
||||
{
|
||||
// pripravenie array na upsert
|
||||
$timesheets = array_map(function($item) {
|
||||
$item['user_id'] = $item['employee_id'];
|
||||
unset($item['employee_id']);
|
||||
$item['sub_task_id'] = $this->id;
|
||||
return $item;
|
||||
}, $timesheets);
|
||||
|
||||
$this->timesheets()->upsert($timesheets, ['id']);
|
||||
|
||||
// zmazanie vykazov, ktore boli poslane z frontendu
|
||||
$this->timesheets()->whereNotIn('id', collect($timesheets)->pluck('id'))->delete();
|
||||
}
|
||||
|
||||
public function syncTimeblocks(Array $timeblocks)
|
||||
{
|
||||
// pripravenie array na upsert
|
||||
$timeblocks = array_map(function($item) {
|
||||
$item['sub_task_id'] = $this->id;
|
||||
return $item;
|
||||
}, $timeblocks);
|
||||
|
||||
$this->timeblocks()->upsert($timeblocks, ['id']);
|
||||
|
||||
// zmazanie vykazov, ktore boli poslane z frontendu
|
||||
$this->timeblocks()->whereNotIn('id', collect($timeblocks)->pluck('id'))->delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ class Timeblock extends Model
|
||||
use HasFactory;
|
||||
|
||||
public $timestamps = true;
|
||||
public $guarded = ['id'];
|
||||
|
||||
public function subtask()
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ class Timesheet extends Model
|
||||
use HasFactory;
|
||||
|
||||
public $timestamps = true;
|
||||
public $guarded = ['id'];
|
||||
|
||||
public function subtask()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user