mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 06:20:21 +00:00
POST subtask/{id}/timesheet
This commit is contained in:
1 parent
0d2a659049
commit
ef2ab75ce4
2 files changed
+21
-9
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -45,13 +46,15 @@ class SubTask extends Model
|
||||
$item['user_id'] = $item['employee_id'];
|
||||
unset($item['employee_id']);
|
||||
$item['sub_task_id'] = $this->id;
|
||||
$item['created_at'] = Carbon::now();
|
||||
$item['updated_at'] = Carbon::now();
|
||||
return $item;
|
||||
}, $timesheets);
|
||||
|
||||
$this->timesheets()->upsert($timesheets, ['id']);
|
||||
// zmazanie vykazov, ktore neboli poslane z frontendu
|
||||
$this->timesheets()->whereNotIn('id', collect($timesheets)->pluck('id')->filter())->delete();
|
||||
|
||||
// zmazanie vykazov, ktore boli poslane z frontendu
|
||||
$this->timesheets()->whereNotIn('id', collect($timesheets)->pluck('id'))->delete();
|
||||
$this->timesheets()->upsert($timesheets, ['id']);
|
||||
}
|
||||
|
||||
public function syncTimeblocks(Array $timeblocks)
|
||||
@@ -62,10 +65,21 @@ class SubTask extends Model
|
||||
return $item;
|
||||
}, $timeblocks);
|
||||
|
||||
$this->timeblocks()->upsert($timeblocks, ['id']);
|
||||
// zmazanie vykazov, ktore neboli poslane z frontendu
|
||||
$this->timeblocks()->whereNotIn('id', collect($timeblocks)->pluck('id')->filter())->delete();
|
||||
|
||||
// zmazanie vykazov, ktore boli poslane z frontendu
|
||||
$this->timeblocks()->whereNotIn('id', collect($timeblocks)->pluck('id'))->delete();
|
||||
$this->timeblocks()->upsert($timeblocks, ['id']);
|
||||
}
|
||||
|
||||
public function deleteAttachments()
|
||||
{
|
||||
foreach ( $this->attachments as $attachment ) {
|
||||
$attachment->deleteFromS3();
|
||||
}
|
||||
|
||||
$this->attachments()->delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -81,9 +81,7 @@ Route::put('/v1/subtasks/{id}', SubTaskController::class . '@update');
|
||||
Route::get('/v1/subtasks/{id}', function ($id) {
|
||||
return new SubTaskResource( SubTask::find($id));
|
||||
});
|
||||
Route::get('/v1/subtasks/{id}', function ($id) {
|
||||
return new SubTaskResource( SubTask::find($id));
|
||||
});
|
||||
Route::post('/v1/subtasks/{id}/timesheet', SubTaskController::class . '@submitTimesheet');
|
||||
|
||||
Route::get('/v1/subtasks',SubTaskController::class . '@index');
|
||||
|
||||
|
||||
Reference in new issue
Block a user