55 lines
1.7 KiB
PHP
55 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Staff;
|
|
|
|
use App\Domain\ACL\Permission;
|
|
use App\Http\Controllers\HashidControllerBase;
|
|
use App\Http\Requests\StudyHistoryRequest;
|
|
use App\Models\Study;
|
|
use App\Models\StudyDetails;
|
|
use App\Services\AuditTrail\Activity;
|
|
use App\Services\SessionHelper;
|
|
|
|
class HistoryController extends HashidControllerBase
|
|
{
|
|
public function view()
|
|
{
|
|
abort_unless(auth()->user()->may(Permission::StudyHistoryView), 403);
|
|
$this->decodeKeys();
|
|
$details = StudyDetails::historyOnly($this->key);
|
|
$study = Study::findOrFail($this->key);
|
|
|
|
return view('staff.history.view', compact('details', 'study'));
|
|
}
|
|
|
|
public function edit()
|
|
{
|
|
// SessionHelper::setIntendedUrl();
|
|
abort_unless(auth()->user()->may(Permission::StudyHistoryEdit), 403);
|
|
$this->decodeKeys();
|
|
$details = StudyDetails::historyOnly($this->key);
|
|
$study = Study::findOrFail($this->key);
|
|
|
|
return view('staff.history.edit', compact('details', 'study'));
|
|
}
|
|
|
|
public function save(StudyHistoryRequest $request)
|
|
{
|
|
abort_unless(auth()->user()->may(Permission::StudyHistoryEdit), 403);
|
|
$this->decodeKeys();
|
|
$details = StudyDetails::historyOnly($this->key);
|
|
$payload = array_trim_strings($request->validated());
|
|
unset($payload['study_id']);
|
|
$details->update($payload);
|
|
|
|
audit()
|
|
->did(Activity::Study_History_Edit)
|
|
->on($this->key)
|
|
->log();
|
|
|
|
// return redirect()->route('staff.history.view', _h($this->key));
|
|
// return SessionHelper::redirectIntended();
|
|
return view('content.pages.close-window');
|
|
}
|
|
}
|