firstcommit

This commit is contained in:
2025-08-17 16:23:14 +05:45
commit 76bf4c0a18
2648 changed files with 362795 additions and 0 deletions

View File

@@ -0,0 +1,108 @@
<?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();
}
}
}

View File

@@ -0,0 +1,67 @@
<?php
namespace Modules\Consultation\app\Http\Requests;
use Modules\Consultation\app\Helpers\Options;
use Illuminate\Foundation\Http\FormRequest;
class CreateConsultationRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
return [
'name' => 'required|string|max:200|regex:/^[a-zA-Z. ]+$/',
'email' => 'sometimes|nullable|email|max:255',
'contact_no' => 'required|string|max:20',
'age_group' => 'required|integer|between:1,7',
'procedure_of_interest' => 'required|integer|between:1,5',
'subject' => 'required|string|max:255',
'message' => 'required|string',
'is_aggrement' => 'required|in:10,11',
];
}
public function messages()
{
return [
'name.required' => 'The name field is required.',
'name.string' => 'The name field must be a string.',
'name.max' => 'The name may not be greater than :max characters.',
'name.regex' => 'The name field may only contain letters, spaces, and dots.',
'email.email' => 'The email must be a valid email address.',
'email.max' => 'The email may not be greater than :max characters.',
'contact_no.required' => 'The contact number field is required.',
'contact_no.max' => 'The contact number may not be greater than :max characters.',
'age_group.required' => 'The age group field is required.',
'age_group.integer' => 'The age group must be an integer.',
'age_group.between' => 'The age group must be between :min and :max.',
'procedure_of_interest.required' => 'The procedure of interest field is required.',
'procedure_of_interest.integer' => 'The procedure of interest must be an integer.',
'procedure_of_interest.between' => 'The procedure of interest must be between :min and :max.',
'subject.required' => 'The subject field is required.',
'subject.string' => 'The subject field must be a string.',
'subject.max' => 'The subject may not be greater than :max characters.',
'message.required' => 'The message field is required.',
'is_aggrement.required' => 'The agreement field is required.',
'is_aggrement.in' => 'Invalid value for the agreement field.',
];
}
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
}