refactor: rename agreement to proof

This commit is contained in:
2025-11-29 14:56:33 +01:00
parent 5b84b67a65
commit 6801132921
10 changed files with 57 additions and 47 deletions

View File

@@ -61,7 +61,7 @@ class InternshipController extends Controller
return response()->json($internship);
}
public function get_default_agreement(Request $request, int $id)
public function get_default_proof(Request $request, int $id)
{
$user = auth()->user();
$internship = Internship::find($id);
@@ -78,7 +78,7 @@ class InternshipController extends Controller
$contact = User::find($internship->company->contact);
$html = view('agreement.default', [
$html = view('proof.default', [
'company' => $internship->company,
'companyContact' => $contact,
'internship' => $internship,
@@ -93,10 +93,10 @@ class InternshipController extends Controller
return response($pdf->Output('', 'S'), 200)
->header('Content-Type', 'application/pdf')
->header('Content-Disposition', 'attachment; filename="agreement_' . $id . '.pdf"');
->header('Content-Disposition', 'attachment; filename="proof_' . $id . '.pdf"');
}
public function get_agreement(int $id)
public function get_proof(int $id)
{
$user = auth()->user();
$internship = Internship::find($id);
@@ -107,9 +107,9 @@ class InternshipController extends Controller
], 400);
}
if (!$internship->agreement) {
if (!$internship->proof) {
return response()->json([
'message' => 'No agreement file exists for this internship.'
'message' => 'No proof file exists for this internship.'
], 404);
}
@@ -117,9 +117,9 @@ class InternshipController extends Controller
abort(403, 'Unauthorized');
}
return response($internship->agreement, 200)
return response($internship->proof, 200)
->header('Content-Type', 'application/pdf')
->header('Content-Disposition', 'attachment; filename="agreement_' . $id . '.pdf"');
->header('Content-Disposition', 'attachment; filename="proof_' . $id . '.pdf"');
}
public function get_report(int $id)
@@ -182,7 +182,7 @@ class InternshipController extends Controller
'year_of_study' => $request->year_of_study,
'semester' => $request->semester,
'position_description' => $request->position_description,
'agreement' => null
'proof' => null
]);
InternshipStatusData::create([
@@ -250,13 +250,13 @@ class InternshipController extends Controller
}
$request->validate([
'agreement' => ['nullable', 'file', 'mimes:pdf', 'max:10240'],
'proof' => ['nullable', 'file', 'mimes:pdf', 'max:10240'],
'report' => ['nullable', 'file', 'mimes:pdf', 'max:10240'],
'report_confirmed' => ['required', 'boolean'],
]);
if ($request->hasFile('agreement')) {
$internship->agreement = file_get_contents($request->file('agreement')->getRealPath());
if ($request->hasFile('proof')) {
$internship->proof = file_get_contents($request->file('proof')->getRealPath());
}
if ($request->hasFile('report')) {
@@ -264,9 +264,9 @@ class InternshipController extends Controller
}
if ($user->role === 'EMPLOYER') {
if ($request->report_confirmed && (!$internship->agreement || !$internship->report)) {
if ($request->report_confirmed && (!$internship->proof || !$internship->report)) {
return response()->json([
'message' => 'Report cannot be confirmed without an agreement and report.'
'message' => 'Report cannot be confirmed without an proof and report.'
], 400);
}

View File

@@ -25,7 +25,7 @@ class Internship extends Model
'year_of_study',
'semester',
'position_description',
'agreement',
'proof',
'report',
'report_confirmed',
];
@@ -135,7 +135,7 @@ class Internship extends Model
'year_of_study' => $this->year_of_study,
'semester' => $this->semester,
'position_description' => $this->position_description,
'agreement' => $this->agreement !== null,
'proof' => $this->proof !== null,
'report' => $this->report !== null,
'report_confirmed' => $this->report_confirmed,
'status' => $this->status,

View File

@@ -27,7 +27,7 @@ class InternshipFactory extends Factory
'year_of_study' => fake()->randomElement([1, 2, 3, 4, 5]),
'semester' => fake()->randomElement(["WINTER", "SUMMER"]),
'position_description' => fake()->jobTitle(),
'agreement' => null,
'proof' => null,
'report' => null,
'report_confirmed' => false,
];

View File

@@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
return new class extends Migration {
/**
* Run the migrations.
*/
@@ -20,7 +19,7 @@ return new class extends Migration
$table->unsignedSmallInteger("year_of_study")->nullable(false);
$table->enum("semester", ["WINTER", "SUMMER"])->nullable(false);
$table->string("position_description")->nullable(false);
$table->binary("agreement")->nullable(true);
$table->binary("proof")->nullable(true);
$table->binary("report")->nullable(true);
$table->boolean("report_confirmed")->nullable(false)->default(false);
$table->timestamps();

View File

@@ -49,8 +49,8 @@ Route::prefix('/internships')->group(function () {
Route::put("/status", [InternshipStatusDataController::class, 'update'])->name("api.internships.status.update");
Route::get("/statuses", [InternshipStatusDataController::class, 'get'])->name("api.internships.get");
Route::get("/next-statuses", [InternshipStatusDataController::class, 'get_next_states'])->name("api.internships.status.next.get");
Route::get("/default-agreement", [InternshipController::class, 'get_default_agreement'])->name("api.internships.agreement.default.get");
Route::get("/agreement", [InternshipController::class, 'get_agreement'])->name("api.internships.agreement.get");
Route::get("/default-proof", [InternshipController::class, 'get_default_proof'])->name("api.internships.proof.default.get");
Route::get("/proof", [InternshipController::class, 'get_proof'])->name("api.internships.proof.get");
Route::get("/report", [InternshipController::class, 'get_report'])->name("api.internships.report.get");
Route::post("/documents", [InternshipController::class, 'update_documents'])->name("api.internships.documents.set");
Route::post("/basic", [InternshipController::class, 'update_basic'])->name("api.internships.update.basic");