Enhance careers management features: update CareersPageController to fetch and display career listings with additional fields, modify Career model to include relationships and new attributes, and create a new view for the careers index with an application modal. Update database migration to reflect changes in the careers table structure and adjust routes for application submissions.
This commit is contained in:
36
app/Http/Controllers/ApplicationController.php
Normal file
36
app/Http/Controllers/ApplicationController.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Application;
|
||||
|
||||
class ApplicationController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
'career_id' => 'required|exists:careers,id',
|
||||
'name' => 'required|string|max:255',
|
||||
'birthdate' => 'required|date',
|
||||
'resume_file' => 'required|file|mimes:pdf,doc,docx|max:2048',
|
||||
'email' => 'required|email|max:255',
|
||||
'phone_number' => 'required|string|max:20',
|
||||
'cover_letter' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$resumePath = $request->file('resume_file')->store('resumes');
|
||||
|
||||
Application::create([
|
||||
'career_id' => $validatedData['career_id'],
|
||||
'name' => $validatedData['name'],
|
||||
'birthdate' => $validatedData['birthdate'],
|
||||
'resume_file' => $resumePath,
|
||||
'email' => $validatedData['email'],
|
||||
'phone_number' => $validatedData['phone_number'],
|
||||
'cover_letter' => $validatedData['cover_letter'] ?? null,
|
||||
]);
|
||||
|
||||
return back()->with('success', 'Your application has been submitted successfully!');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user