This commit is contained in:
Masroor Ehsan 2024-12-30 20:57:17 +06:00
parent a89c2690a1
commit 0c2dcc62cb
6 changed files with 47 additions and 28 deletions

View File

@ -21,6 +21,7 @@ public function details()
$this->decodeKeys();
$study = Study::with(['series', 'details'])->findOrFail($this->key);
return view('staff.studies.details', compact('study'));
//return view('staff.studies.details', compact('study'));
return response()->json($study);
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class SharedStudyRequest extends FormRequest
{
public function rules(): array
{
return [
];
}
public function authorize(): bool
{
return true;
}
}

View File

@ -1,23 +0,0 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StudyShareRequest extends FormRequest
{
public function rules(): array
{
return [
'study_id' => ['required', 'exists:studies'],
'user_id' => ['required', 'exists:users'],
'operator_id' => ['nullable', 'exists:users'],
'expires_on' => ['nullable', 'date'],
];
}
public function authorize(): bool
{
return true;
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace App\Http\Resources;
use App\Models\SharedStudy;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/** @mixin SharedStudy */
class SharedStudyResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}

View File

@ -5,7 +5,7 @@
use App\Models\Enums\StudyAccessFlags;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class StudyShare extends BaseModel
class SharedStudy extends BaseModel
{
public function study(): BelongsTo
{

View File

@ -9,14 +9,15 @@
{
public function up(): void
{
Schema::create('study_shares', function (Blueprint $table) {
Schema::create('shared_studies', function (Blueprint $table) {
$table->id();
$table->foreignId('study_id')->index()->constrained('studies')->cascadeOnDelete();
$table->foreignId('recipient_id')->index()->constrained('users')->cascadeOnDelete();
$table->foreignId('recipient_id')->nullable()->index()->constrained('users')->cascadeOnDelete();
$table->foreignId('sender_id')->nullable()->constrained('users')->nullOnDelete();
$table->unsignedTinyInteger('access_flags')->default(StudyAccessFlags::Forbidden->value);
$table->string('access_password')->nullable();
$table->dateTime('expires_at')->nullable();
$table->string('remarks')->nullable();
$table->timestamps();
$table->unique(['study_id', 'recipient_id']);
@ -25,6 +26,6 @@ public function up(): void
public function down(): void
{
Schema::dropIfExists('study_shares');
Schema::dropIfExists('shared_studies');
}
};