46 lines
1.4 KiB
PHP
46 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Staff;
|
|
|
|
use App\Http\Controllers\HashidControllerBase;
|
|
use App\Http\Requests\StudyHistoryRequest;
|
|
use App\Models\Enums\Permission;
|
|
use App\Models\Study;
|
|
use App\Models\StudyDetails;
|
|
|
|
class StudyHistoryController 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()
|
|
{
|
|
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);
|
|
|
|
// return redirect()->route('staff.history.view', _h($this->key));
|
|
return redirect()->route('staff.history.view', $details->hash);
|
|
}
|
|
}
|