41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\ContactInfo;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ContactInfoController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$contactInfo = ContactInfo::first();
|
|
return view('contact.edit', compact('contactInfo'));
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
$request->validate([
|
|
'title' => 'required|string|max:255',
|
|
'description' => 'nullable|string',
|
|
'name' => 'required|string|max:255',
|
|
'address' => 'nullable|string',
|
|
'phone' => 'nullable|string|max:20',
|
|
'email' => 'nullable|email|max:255',
|
|
'whatsapp' => 'nullable|string|max:20',
|
|
]);
|
|
|
|
ContactInfo::updateOrCreate(
|
|
['id' => 1],
|
|
$request->all()
|
|
);
|
|
|
|
return redirect()->back()->with('success', 'Informasi kontak berhasil diperbarui');
|
|
}
|
|
|
|
public function show()
|
|
{
|
|
$contactInfo = ContactInfo::where('is_active', true)->first();
|
|
return view('contact.hubungikami', compact('contactInfo'));
|
|
}
|
|
}
|