<?php

namespace App\Http\Controllers;

use App\Models\Study;

class HashedStudyControllerBase extends HashidControllerBase
{
    protected ?Study $study = null;

    protected function getStudy(array|string|null $relations = null): Study
    {
        $this->decodeKeys();
        if ($relations !== null) {
            $this->study = Study::with($relations)->findOrFail($this->key);
        } else {
            $this->study = Study::findOrFail($this->key);
        }

        return $this->study;
    }

    protected function lockedNotice()
    {
        return view('content.pages.notice', [
            'title' => 'Study Locked',
            'color' => 'danger',
            'heading' => 'Study Locked',
            'message' => 'Study metadata cannot be edited once the report has been finalized.',
        ]);
    }
}