firstcommit
This commit is contained in:
0
Modules/ContactUs/app/Http/Controllers/.gitkeep
Normal file
0
Modules/ContactUs/app/Http/Controllers/.gitkeep
Normal file
130
Modules/ContactUs/app/Http/Controllers/ContactUsController.php
Normal file
130
Modules/ContactUs/app/Http/Controllers/ContactUsController.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\ContactUs\app\Http\Controllers;
|
||||
|
||||
use App\Mail\ReplyToMail;
|
||||
use App\Jobs\ReplyToMailJob;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\LogoService;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Modules\ContactUs\app\Models\ContactUs;
|
||||
use Modules\ContactUs\app\Repositories\ContactUsRepository;
|
||||
use Modules\ContactUs\app\Http\Requests\CreateContactUsRequest;
|
||||
|
||||
class ContactUsController extends Controller
|
||||
{
|
||||
protected $contactUsRepository;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->contactUsRepository = new ContactUsRepository;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$perPage = $request->has('per-page') ? $request->input('per-page') : null;
|
||||
$filter = $request->has('filter') ? $request->input('filter') : [];
|
||||
$data['contactUsList'] = $this->contactUsRepository->allContactList($perPage, $filter);
|
||||
|
||||
$data['contactUsCount'] = $data['contactUsList']->count();
|
||||
// dd(($data['contactUsCount']));
|
||||
|
||||
return view('contactus::index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
|
||||
public function replyToMail(LogoService $logoService, Request $request, $uuid)
|
||||
{
|
||||
$citizenEmail = ContactUs::where('uuid', $uuid)->first();
|
||||
if (!$citizenEmail) {
|
||||
return null;
|
||||
}
|
||||
dispatch(new ReplyToMailJob(
|
||||
$citizenEmail,
|
||||
$request->content,
|
||||
$logoService->getSiteLogo()
|
||||
));
|
||||
return redirect()->route('cms.contactUs.index');
|
||||
}
|
||||
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('contactus::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(CreateContactUsRequest $request): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$validated = $request->validated();
|
||||
$this->contactUsRepository->storeContactUsList($validated);
|
||||
|
||||
toastr()->success('Contact detail created successfully.');
|
||||
|
||||
return redirect()->route('cms.contactus.index');
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
toastr()->error('Something went wrong.');
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($uuid)
|
||||
{
|
||||
$data['contactUs'] = $this->contactUsRepository->findContactUsListById($uuid);
|
||||
|
||||
return view('contactus::show', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('contactus::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($uuid)
|
||||
{
|
||||
try {
|
||||
$contact_us = $this->contactUsRepository->deleteContactUsList($uuid);
|
||||
|
||||
if (!$contact_us) {
|
||||
toastr()->error('Contact detail not found.');
|
||||
return back();
|
||||
}
|
||||
|
||||
toastr()->success('Contact detail deleted successfully.');
|
||||
|
||||
return redirect()->route('cms.contactus.index');
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
toastr()->error('Something went wrong.');
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user