-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
241ce94
commit 0214f59
Showing
6 changed files
with
259 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Outcome; | ||
use App\Output; | ||
use App\OutputUpdate; | ||
use Carbon\Carbon; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Response; | ||
|
||
class OutcomeController extends Controller | ||
{ | ||
/** | ||
* Update the specified resource in storage. | ||
* | ||
* @param Request $request | ||
* @param int $id | ||
* @return RedirectResponse | ||
*/ | ||
public function update(Request $request, int $id) | ||
{ | ||
$outcome = Outcome::find($id); | ||
$outcome->summary = $request->summary; | ||
$outcome->completed_on = Carbon::now(); | ||
$outcome->user_id = \Auth::user()->id; | ||
$outcome->completed = 1; | ||
$output_updates = array(); | ||
foreach ($request->outcome_outputs as $output) { | ||
$output_id = Output::findorfail($output)->id; | ||
$output_updates[$output_id]['indicator'] = Output::find($output_id)->indicator ?? 0; | ||
$output_updates[$output_id]['value'] = OutputUpdate::where('output_id', $output_id)->get()->last()->value ?? 0; | ||
} | ||
$outcome->outputs = json_encode($output_updates); | ||
$outcome->save(); | ||
return redirect()->route('project_show', $request->project); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.