171 lines
6.1 KiB
PHP
171 lines
6.1 KiB
PHP
<?php
|
||
|
||
namespace App\Http\Controllers;
|
||
|
||
use App\Models\CareerApplication;
|
||
use Illuminate\Http\Request;
|
||
use Illuminate\Support\Facades\Storage;
|
||
|
||
class CareerController extends Controller
|
||
{
|
||
public function index()
|
||
{
|
||
return view('front.career.index', [
|
||
'meta' => [
|
||
'title' => __('career.job_application_title', ['default' => 'İş Başvurusu']),
|
||
'description' => __('career.job_application_description', ['default' => 'Ekibimize katılmak için aşağıdaki formu doldurarak CV\'nizi iletebilirsiniz.']),
|
||
]
|
||
]);
|
||
}
|
||
|
||
public function internship()
|
||
{
|
||
return view('front.career.internship', [
|
||
'meta' => [
|
||
'title' => __('career.internship_title', ['default' => 'Staj Başvurusu']),
|
||
'description' => __('career.internship_description', ['default' => 'Uzaktan staj programımız hakkında bilgi alın ve başvurunuzu yapın.']),
|
||
]
|
||
]);
|
||
}
|
||
|
||
public function store(Request $request)
|
||
{
|
||
$rules = [
|
||
'name' => 'required|string|max:255',
|
||
'email' => 'required|email|max:255',
|
||
'phone' => 'nullable|string|max:20',
|
||
'cv' => 'required|file|mimes:pdf,doc,docx|max:5120', // Max 5MB
|
||
'message' => 'nullable|string',
|
||
];
|
||
|
||
if ($request->type === 'job') {
|
||
$rules['nda'] = 'required|file|mimes:pdf|max:5120';
|
||
$rules['contract'] = 'required|file|mimes:pdf|max:5120';
|
||
$rules['git_knowledge'] = 'accepted';
|
||
$rules['ai_usage'] = 'accepted';
|
||
}
|
||
|
||
$request->validate($rules);
|
||
|
||
$cvPath = $request->file('cv') ? $request->file('cv')->store('cvs', 'public') : null;
|
||
$ndaPath = $request->file('nda') ? $request->file('nda')->store('ndas', 'public') : null;
|
||
$contractPath = $request->file('contract') ? $request->file('contract')->store('contracts', 'public') : null;
|
||
|
||
CareerApplication::create([
|
||
'name' => $request->name,
|
||
'email' => $request->email,
|
||
'phone' => $request->phone,
|
||
'type' => $request->type ?? 'job',
|
||
'cv_path' => $cvPath,
|
||
'nda_path' => $ndaPath,
|
||
'contract_path' => $contractPath,
|
||
'git_knowledge' => $request->has('git_knowledge'),
|
||
'ai_usage' => $request->has('ai_usage'),
|
||
'message' => $request->message,
|
||
'status' => 'pending',
|
||
]);
|
||
|
||
if ($request->ajax()) {
|
||
return response()->json([
|
||
'success' => true,
|
||
'message' => __('career.success_message')
|
||
]);
|
||
}
|
||
|
||
return redirect()->back()->with('success', __('career.success_message'));
|
||
}
|
||
|
||
public function internLoginForm()
|
||
{
|
||
if (session()->has('intern_id')) {
|
||
return redirect()->route('intern.dashboard');
|
||
}
|
||
return view('front.career.intern_login', [
|
||
'meta' => [
|
||
'title' => 'Stajyer Girişi',
|
||
'description' => 'İmzalı staj belgelerinize erişmek için lütfen giriş yapın.',
|
||
]
|
||
]);
|
||
}
|
||
|
||
public function internLogin(Request $request)
|
||
{
|
||
$request->validate([
|
||
'username' => 'required|string',
|
||
'password' => 'required|string',
|
||
]);
|
||
|
||
$intern = CareerApplication::where('username', $request->username)
|
||
->where('type', 'internship')
|
||
->first();
|
||
|
||
if (!$intern || !\Illuminate\Support\Facades\Hash::check($request->password, $intern->password)) {
|
||
return redirect()->back()
|
||
->withInput($request->only('username'))
|
||
->withErrors([
|
||
'username' => 'Girdiğiniz kullanıcı adı veya şifre hatalı.',
|
||
]);
|
||
}
|
||
|
||
session(['intern_id' => $intern->id]);
|
||
|
||
return redirect()->route('intern.dashboard')->with('success', 'Başarıyla giriş yapıldı.');
|
||
}
|
||
|
||
public function internDashboard()
|
||
{
|
||
if (!session()->has('intern_id')) {
|
||
return redirect()->route('intern.login')->with('error', 'Lütfen giriş yapın.');
|
||
}
|
||
|
||
$intern = CareerApplication::findOrFail(session('intern_id'));
|
||
return view('front.career.intern_dashboard', [
|
||
'intern' => $intern,
|
||
'meta' => [
|
||
'title' => 'Stajyer Paneli',
|
||
'description' => 'Belgelerinizi buradan indirebilirsiniz.',
|
||
]
|
||
]);
|
||
}
|
||
|
||
public function uploadInternshipForm(Request $request)
|
||
{
|
||
if (!session()->has('intern_id')) {
|
||
return redirect()->route('intern.login')->with('error', 'Lütfen önce giriş yapın.');
|
||
}
|
||
|
||
$request->validate([
|
||
'internship_form' => 'required|file|mimes:pdf,docx,jpg,png,jpeg|max:51200',
|
||
], [
|
||
'internship_form.required' => 'Lütfen bir dosya seçin.',
|
||
'internship_form.file' => 'Yüklenen öğe geçerli bir dosya olmalıdır.',
|
||
'internship_form.mimes' => 'Yalnızca PDF, DOCX, JPG ve PNG formatındaki dosyalar kabul edilir.',
|
||
'internship_form.max' => 'Dosya boyutu en fazla 50MB olabilir.',
|
||
]);
|
||
|
||
$intern = CareerApplication::findOrFail(session('intern_id'));
|
||
|
||
if ($request->hasFile('internship_form')) {
|
||
// Delete old file if exists
|
||
if ($intern->to_be_signed_internship_form_path) {
|
||
Storage::disk('public')->delete($intern->to_be_signed_internship_form_path);
|
||
}
|
||
|
||
$path = $request->file('internship_form')->store('to_be_signed_interns', 'public');
|
||
$intern->update([
|
||
'to_be_signed_internship_form_path' => $path
|
||
]);
|
||
|
||
return redirect()->back()->with('success', 'İmzalanacak staj formunuz başarıyla yüklendi.');
|
||
}
|
||
|
||
return redirect()->back()->with('error', 'Dosya yüklenirken bir hata oluştu.');
|
||
}
|
||
|
||
public function internLogout()
|
||
{
|
||
session()->forget('intern_id');
|
||
return redirect()->route('intern.login')->with('success', 'Başarıyla çıkış yapıldı.');
|
||
}
|
||
}
|