Permalink
Browse files

Add route for finishing an open time entry

  • Loading branch information...
lovett committed Mar 26, 2018
1 parent 1c2d3f3 commit 127d86df92fd4e6fc7c43f1b0276735d97efdc39
Showing with 27 additions and 1 deletion.
  1. +11 −0 app/Http/Controllers/TimeController.php
  2. +6 −0 app/Time.php
  3. +5 −1 resources/views/time/table.blade.php
  4. +5 −0 routes/web.php
@@ -212,4 +212,15 @@ public function destroy(Request $request, $id)
return redirect()->route('time.index');
}
public function finish(Request $request)
{
$id = $request->input('id', null);
$time = $request->user()->time()->findOrFail($id);
$time->finish();
return redirect()->route('time.index');
}
}
@@ -485,4 +485,10 @@ public function syncTagsFromList($tagList)
$this->tags()->sync($tags);
}
public function finish() {
$this->end = new Carbon();
$this->save();
}
}
@@ -28,7 +28,11 @@
<div class="small">{{ TimeHelper::hoursAndMinutes($time->minutes) }}</div>
@else
?
<p><a href="#" class="btn finish btn-info btn-xs">Finish</a></p>
{!! Form::model($time, ['route' => ['time.finish'], 'method' => 'POST']) !!}
{!! Form::hidden('id', $time->id) !!}
{!! Form::button('FINISH', ['type' => 'submit', 'class' => 'btn finish btn-info btn-xs']) !!}
{!! Form::close() !!}
@endif
</td>
@@ -28,6 +28,11 @@
'uses' => 'TimeController@suggestByProject'
]);
Route::post('time/finish', [
'as' => 'time.finish',
'uses' => 'TimeController@finish',
]);
Route::resource('time', 'TimeController');
Route::resource('estimate', 'EstimateController');

0 comments on commit 127d86d

Please sign in to comment.