This commit is contained in:
Masroor Ehsan 2025-01-08 17:23:15 +06:00
parent f5628a9d54
commit 3f0fbf8222
3 changed files with 14 additions and 11 deletions

View File

@ -149,7 +149,7 @@ public function getReportStatusLedAttribute(): string
public function getArchiveLink(): ?string
{
if (me_or_other()->may(Permission::StudyDownload)) {
if (me()->may(Permission::StudyDownload)) {
return PacsUrlGen::archive($this->study_instance_uid);
}
@ -158,7 +158,7 @@ public function getArchiveLink(): ?string
public function getStoneLink(): ?string
{
if (me_or_other()->may(Permission::StudyDownload)) {
if (me()->may(Permission::StudyDownload)) {
return PacsUrlGen::stoneViewer($this->study_instance_uid);
}
@ -167,7 +167,7 @@ public function getStoneLink(): ?string
public function getOhifLink(): ?string
{
if (me_or_other()->may(Permission::StudyDownload)) {
if (me()->may(Permission::StudyDownload)) {
return PacsUrlGen::ohifViewer($this->study_instance_uid);
}
@ -176,7 +176,7 @@ public function getOhifLink(): ?string
public function getOhifSegmentationLink(): ?string
{
if (me_or_other()->may(Permission::StudyDownload)) {
if (me()->may(Permission::StudyDownload)) {
return PacsUrlGen::ohifSegmentation($this->study_instance_uid);
}
@ -185,7 +185,7 @@ public function getOhifSegmentationLink(): ?string
public function getOhifMprLink(): ?string
{
if (me_or_other()->may(Permission::StudyDownload)) {
if (me()->may(Permission::StudyDownload)) {
return PacsUrlGen::ohifViewerMpr($this->study_instance_uid);
}
@ -302,7 +302,7 @@ public function lockStudy(User|int|null $user = null): void
{
$this->update(
[
'locking_physician_id' => me_or_other($user)->id,
'locking_physician_id' => me($user)->id,
'locked_at' => now(),
]
);
@ -375,11 +375,11 @@ protected function casts(): array
public function isLockedBy(User|int|null $user = null): bool
{
return $this->locking_physician_id === me_or_other($user)->id;
return $this->locking_physician_id === me($user)->id;
}
public function isAssignedTo(User|int|null $user = null): bool
{
return $this->assigned_physician_id === me_or_other($user)->id;
return $this->assigned_physician_id === me($user)->id;
}
}

View File

@ -21,7 +21,7 @@ public static function of(Study $study): self
public function by(User|int|null $user): self
{
$this->user = me_or_other($user);
$this->user = me($user);
return $this;
}

View File

@ -112,8 +112,11 @@ function thumb_url(Media $media): string
}
}
if (! function_exists('me_or_other')) {
function me_or_other(User|int|null $user = null): User
if (! function_exists('me')) {
/**
* Gets the user. If no user is provided, it will return the authenticated user.
*/
function me(User|int|null $user = null): User
{
if (is_int($user) && $user > 0) {
return User::find($user);