V2, better design, more functionalities.
This commit is contained in:
21
app/Http/Controllers/ContactController.php
Normal file
21
app/Http/Controllers/ContactController.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class ContactController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|max:255',
|
||||
'message' => 'required|max:5000',
|
||||
]);
|
||||
|
||||
|
||||
|
||||
return response()->json(['status' => 'success']);
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class EducationController extends Controller
|
||||
$education = Education::create($data);
|
||||
|
||||
if ($request->hasFile('afbeelding')) {
|
||||
$education->addMediaFromRequest('afbeelding')->toMediaCollection('afbeelding');
|
||||
$education->addMediaFromRequest('afbeelding')->toMediaCollection('image');
|
||||
}
|
||||
|
||||
return redirect()->route('educations.index')->with('success', 'Opleiding toegevoegd.');
|
||||
@@ -62,8 +62,9 @@ class EducationController extends Controller
|
||||
$education->update($data);
|
||||
|
||||
if ($request->hasFile('afbeelding')) {
|
||||
$education->clearMediaCollection('afbeelding');
|
||||
$education->addMediaFromRequest('afbeelding')->toMediaCollection('afbeelding');
|
||||
$education->clearMediaCollection('image');
|
||||
|
||||
$education->addMediaFromRequest('afbeelding')->toMediaCollection('image');
|
||||
}
|
||||
|
||||
return redirect()->route('educations.index')->with('success', 'Opleiding bijgewerkt.');
|
||||
|
||||
@@ -7,15 +7,55 @@ use App\Models\Personalia;
|
||||
use App\Models\Skill;
|
||||
use App\Models\WorkExperience;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Jobs\NotifyTelegramAboutPersonaliaClick;
|
||||
use App\Jobs\NotifyTelegramAboutContactMessage;
|
||||
|
||||
class FrontendController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$skills = Skill::all();
|
||||
$skills = Skill::all()->groupBy('type');
|
||||
|
||||
$personalia = Personalia::all();
|
||||
$education = Education::all();
|
||||
$experience = WorkExperience::all();
|
||||
$education = Education::orderBy('startdatum', 'desc')->get();
|
||||
$experience = WorkExperience::orderBy('startdatum', 'desc')->get();
|
||||
|
||||
return view('welcome', compact('skills', 'personalia', 'education', 'experience'));
|
||||
}
|
||||
|
||||
public function getPersonalia($id)
|
||||
{
|
||||
$item = Personalia::findOrFail($id);
|
||||
NotifyTelegramAboutPersonaliaClick::dispatch(
|
||||
$item,
|
||||
request()->ip(),
|
||||
request()->userAgent()
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'value' => $item->value,
|
||||
]);
|
||||
}
|
||||
|
||||
public function message(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'message' => 'required|string|max:5000',
|
||||
'email' => 'nullable|email|max:255',
|
||||
'phone' => 'nullable|string|max:50',
|
||||
]);
|
||||
|
||||
NotifyTelegramAboutContactMessage::dispatch(
|
||||
$validated['name'],
|
||||
$validated['message'],
|
||||
$request->ip(),
|
||||
$request->userAgent(),
|
||||
$validated['email'] ?? null,
|
||||
$validated['phone'] ?? null
|
||||
);
|
||||
|
||||
return response()->json(['status' => 'success']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,11 +29,14 @@ class SkillController extends Controller
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
|
||||
$validated = $request->validate([
|
||||
'title' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'rating' => 'required|integer|min:1|max:10',
|
||||
'rating' => 'required|numeric|min:1|max:10',
|
||||
'image' => 'nullable|image|max:2048',
|
||||
'type' => 'required|in:rating,tag,other',
|
||||
|
||||
]);
|
||||
|
||||
$skill = Skill::create($validated);
|
||||
@@ -69,8 +72,10 @@ class SkillController extends Controller
|
||||
$validated = $request->validate([
|
||||
'title' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'rating' => 'required|integer|min:1|max:10',
|
||||
'rating' => 'required|numeric|min:1|max:10',
|
||||
'image' => 'nullable|image|max:2048',
|
||||
'type' => 'required|in:rating,tag,other',
|
||||
|
||||
]);
|
||||
|
||||
$skill->update($validated);
|
||||
|
||||
@@ -31,7 +31,7 @@ class WorkExperienceController extends Controller
|
||||
$experience = WorkExperience::create($data);
|
||||
|
||||
if ($request->hasFile('afbeelding')) {
|
||||
$experience->addMediaFromRequest('afbeelding')->toMediaCollection('afbeelding');
|
||||
$experience->addMediaFromRequest('afbeelding')->toMediaCollection('image');
|
||||
}
|
||||
|
||||
return redirect()->route('work-experiences.index')->with('success', 'Ervaring toegevoegd.');
|
||||
@@ -58,11 +58,13 @@ class WorkExperienceController extends Controller
|
||||
'afbeelding' => 'nullable|image|max:2048',
|
||||
]);
|
||||
|
||||
|
||||
|
||||
$workExperience->update($data);
|
||||
|
||||
if ($request->hasFile('afbeelding')) {
|
||||
$workExperience->clearMediaCollection('afbeelding');
|
||||
$workExperience->addMediaFromRequest('afbeelding')->toMediaCollection('afbeelding');
|
||||
$workExperience->clearMediaCollection('image');
|
||||
$workExperience->addMediaFromRequest('afbeelding')->toMediaCollection('image');
|
||||
}
|
||||
|
||||
return redirect()->route('work-experiences.index')->with('success', 'Ervaring bijgewerkt.');
|
||||
|
||||
Reference in New Issue
Block a user