This commit is contained in:
Masroor Ehsan 2025-01-08 17:35:28 +06:00
parent 3f0fbf8222
commit 93850de7e3
4 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,23 @@
<?php
namespace App\Http\Controllers\Staff;
use App\Domain\ACL\Permission;
use App\Http\Controllers\HashidControllerBase;
use App\Models\Study;
class ReportController extends HashidControllerBase
{
public function popup()
{
abort_unless(me()->may([Permission::ReportEdit, Permission::ReportDictate, Permission::ReportDownload]), 403);
$this->decodeKeys();
$study = Study::with('reports')->findOrFail($this->key);
if (me()->isRadiologist()) {
abort_unless($study->isAssignedTo(), 403);
}
$reports = $study->reports->sortByDesc('created_at');
return view('staff.reports.popup', compact('study', 'reports'));
}
}

View File

@ -9,6 +9,7 @@
use App\Models\Traits\HashableId;
use App\Services\Pacs\PacsUrlGen;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Concerns\HasTimestamps;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
@ -20,6 +21,7 @@
class Study extends BaseModel implements HasMedia
{
use HashableId;
use HasTimestamps;
use InteractsWithMedia;
public const string MEDIA_COLLECTION = 'attachments';
@ -312,6 +314,7 @@ public function unlockStudy(): void
{
$this->update(
[
'locking_physician_id' => null,
'locked_at' => null,
]
);

View File

@ -90,6 +90,14 @@ public function isAdmin(): bool
);
}
public function isRadiologist(): bool
{
return cache()->remember('user.is_rad:' . $this->id,
5 * 60,
fn () => $this->hasRole(Role::Radiologist)
);
}
public function isTech(): bool
{
return cache()->remember('user.is_tech:' . $this->id,