diff --git a/app/Http/Controllers/Staff/StudiesController.php b/app/Http/Controllers/Staff/StudiesController.php index ef8c20d..b5fd47c 100644 --- a/app/Http/Controllers/Staff/StudiesController.php +++ b/app/Http/Controllers/Staff/StudiesController.php @@ -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); } } diff --git a/app/Http/Requests/SharedStudyRequest.php b/app/Http/Requests/SharedStudyRequest.php new file mode 100644 index 0000000..e3da160 --- /dev/null +++ b/app/Http/Requests/SharedStudyRequest.php @@ -0,0 +1,20 @@ + ['required', 'exists:studies'], - 'user_id' => ['required', 'exists:users'], - 'operator_id' => ['nullable', 'exists:users'], - 'expires_on' => ['nullable', 'date'], - ]; - } - - public function authorize(): bool - { - return true; - } -} diff --git a/app/Http/Resources/SharedStudyResource.php b/app/Http/Resources/SharedStudyResource.php new file mode 100644 index 0000000..b7d712e --- /dev/null +++ b/app/Http/Resources/SharedStudyResource.php @@ -0,0 +1,20 @@ + $this->id, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]; + } +} diff --git a/app/Models/StudyShare.php b/app/Models/SharedStudy.php similarity index 94% rename from app/Models/StudyShare.php rename to app/Models/SharedStudy.php index 37d2d68..45a7a0e 100644 --- a/app/Models/StudyShare.php +++ b/app/Models/SharedStudy.php @@ -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 { diff --git a/database/migrations/2024_12_30_123151_create_study_shares_table.php b/database/migrations/2024_12_30_144956_create_shared_studies_table.php similarity index 75% rename from database/migrations/2024_12_30_123151_create_study_shares_table.php rename to database/migrations/2024_12_30_144956_create_shared_studies_table.php index 1326237..f2f2147 100644 --- a/database/migrations/2024_12_30_123151_create_study_shares_table.php +++ b/database/migrations/2024_12_30_144956_create_shared_studies_table.php @@ -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'); } };