mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +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;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
@@ -45,13 +46,15 @@ class SubTask extends Model
|
|||||||
$item['user_id'] = $item['employee_id'];
|
$item['user_id'] = $item['employee_id'];
|
||||||
unset($item['employee_id']);
|
unset($item['employee_id']);
|
||||||
$item['sub_task_id'] = $this->id;
|
$item['sub_task_id'] = $this->id;
|
||||||
|
$item['created_at'] = Carbon::now();
|
||||||
|
$item['updated_at'] = Carbon::now();
|
||||||
return $item;
|
return $item;
|
||||||
}, $timesheets);
|
}, $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()->upsert($timesheets, ['id']);
|
||||||
$this->timesheets()->whereNotIn('id', collect($timesheets)->pluck('id'))->delete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function syncTimeblocks(Array $timeblocks)
|
public function syncTimeblocks(Array $timeblocks)
|
||||||
@@ -62,10 +65,21 @@ class SubTask extends Model
|
|||||||
return $item;
|
return $item;
|
||||||
}, $timeblocks);
|
}, $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()->upsert($timeblocks, ['id']);
|
||||||
$this->timeblocks()->whereNotIn('id', collect($timeblocks)->pluck('id'))->delete();
|
}
|
||||||
|
|
||||||
|
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) {
|
Route::get('/v1/subtasks/{id}', function ($id) {
|
||||||
return new SubTaskResource( SubTask::find($id));
|
return new SubTaskResource( SubTask::find($id));
|
||||||
});
|
});
|
||||||
Route::get('/v1/subtasks/{id}', function ($id) {
|
Route::post('/v1/subtasks/{id}/timesheet', SubTaskController::class . '@submitTimesheet');
|
||||||
return new SubTaskResource( SubTask::find($id));
|
|
||||||
});
|
|
||||||
|
|
||||||
Route::get('/v1/subtasks',SubTaskController::class . '@index');
|
Route::get('/v1/subtasks',SubTaskController::class . '@index');
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user