109 lines
2.9 KiB
PHP
109 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace Modules\Consultation\app\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Response;
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Modules\Consultation\app\Repositories\ConsultationRepository;
|
|
use Modules\Consultation\app\Http\Requests\CreateConsultationRequest;
|
|
|
|
class ConsultationController extends Controller
|
|
{
|
|
protected $consultationRepository;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->consultationRepository = new ConsultationRepository;
|
|
}
|
|
/**
|
|
* 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['consultations'] = $this->consultationRepository->allConsultationList($perPage, $filter);
|
|
|
|
$data['consultationCount'] = $data['consultations']->count();
|
|
return view('consultation::index', $data);
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*/
|
|
public function create()
|
|
{
|
|
return view('consultation::create');
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(CreateConsultationRequest $request): RedirectResponse
|
|
{
|
|
try {
|
|
$validated = $request->validated();
|
|
$this->consultationRepository->storeConsultationList($validated);
|
|
|
|
toastr()->success('Consultation created successfully.');
|
|
|
|
return redirect()->route('doctor_provider');
|
|
} catch (\Throwable $th) {
|
|
report($th);
|
|
toastr()->error('Something went wrong.');
|
|
return back();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Show the specified resource.
|
|
*/
|
|
public function show($uuid)
|
|
{
|
|
$data['consultation'] = $this->consultationRepository->findConsultationListById($uuid);
|
|
|
|
return view('consultation::show', $data);
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*/
|
|
public function edit($id)
|
|
{
|
|
return view('consultation::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 {
|
|
$consultation = $this->consultationRepository->deleteConsultationList($uuid);
|
|
|
|
if (!$consultation) {
|
|
toastr()->error('Consultation not found.');
|
|
return back();
|
|
}
|
|
|
|
toastr()->success('Consultation deleted successfully.');
|
|
|
|
return redirect()->route('cms.consultation.index');
|
|
} catch (\Throwable $th) {
|
|
report($th);
|
|
toastr()->error('Something went wrong.');
|
|
return back();
|
|
}
|
|
}
|
|
}
|