add some test
This commit is contained in:
@@ -63,12 +63,17 @@ class TimeTrackerController extends Controller
|
||||
{
|
||||
abort_if($timeTracker->toDo->user_id !== $request->user()->id, 401, __('auth.unauthorized'));
|
||||
|
||||
$beforeDelay = $timeTracker->end_at->diffInSeconds($timeTracker->start_at);
|
||||
$data = $request->validate([
|
||||
'start_at' => ['required', 'date'],
|
||||
'end_at' => ['nullable', 'date', 'after_or_equal:start_at'],
|
||||
]);
|
||||
|
||||
$timeTracker->update($data);
|
||||
$timeTracker->fresh();
|
||||
$afterDelay = $timeTracker->end_at->diffInSeconds($timeTracker->start_at);
|
||||
|
||||
$timeTracker->toDo->increment('duration', $afterDelay - $beforeDelay);
|
||||
|
||||
return response()->json(new TimeTrackerResource($timeTracker));
|
||||
}
|
||||
@@ -76,9 +81,16 @@ class TimeTrackerController extends Controller
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(TimeTracker $timeTracker)
|
||||
public function destroy(Request $request, TimeTracker $timeTracker)
|
||||
{
|
||||
//
|
||||
abort_if($timeTracker->toDo->user_id !== $request->user()->id, 401, __('auth.unauthorized'));
|
||||
|
||||
$delay = $timeTracker->end_at->diffInSeconds($timeTracker->start_at);
|
||||
$timeTracker->toDo->decrement('duration', $delay);
|
||||
|
||||
$timeTracker->delete();
|
||||
|
||||
return response()->noContent();
|
||||
}
|
||||
|
||||
public function userTimeTracker(Request $request)
|
||||
|
||||
Reference in New Issue
Block a user