0% found this document useful (0 votes)
7 views479 pages

Formatted Code Documentation

The document is a PHP script containing various helper functions for an application, primarily focused on user authentication, settings retrieval, and managing doctor sessions. It includes functions to get user details, application settings, and various URLs based on user roles and permissions. Additionally, it provides utilities for handling notifications, scheduling, and payment gateways.

Uploaded by

HasSoOna 7S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views479 pages

Formatted Code Documentation

The document is a PHP script containing various helper functions for an application, primarily focused on user authentication, settings retrieval, and managing doctor sessions. It includes functions to get user details, application settings, and various URLs based on user roles and permissions. Additionally, it provides utilities for handling notifications, scheduling, and payment gateways.

Uploaded by

HasSoOna 7S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

[extracted_code > app > helpers.

php]
1: <?php
2: use App\Models\City;
3: use App\Models\Currency;
4: use App\Models\DoctorSession;
5: use App\Models\Notification;
6: use App\Models\Patient;
7: use App\Models\PaymentGateway;
8: use App\Models\Setting;
9: use App\Models\State;
10: use App\Models\User;
11: use App\Models\ZoomOAuth;
12: use App\Providers\RouteServiceProvider;
13: use Carbon\Carbon;
14: use Carbon\CarbonPeriod;
15: use Illuminate\Contracts\Auth\Authenticatable;
16: use Illuminate\Database\Eloquent\HigherOrderBuilderProxy;
17: use Illuminate\Support\Facades\Auth;
18: use Illuminate\Support\Facades\Cache;
19: use Stripe\Stripe;
20: /**
21: * @return Authenticatable|null
22: */
23: function getLogInUser()
24: {
25: return Auth::user();
26: }
27: /**
28: * @return mixed
29: */
30: function getAppName()
31: {
32: static $setting;
33: if (empty($setting)) {
34: $setting = Setting::all()->keyBy('key');
35: }
36: return $setting['clinic_name']->value;
37: }
38: /**
39: * @return mixed
40: */
41: function getAppLogo()
42: {
43: static $setting;
44: if (empty($setting)) {
45: $setting = Setting::all()->keyBy('key');
46: }
47: return $setting['logo']->value;
48: }
49: /**
50: * @return mixed
51: */
52: function getAppFavicon()
53: {
54: static $setting;
55: if (empty($setting)) {
56: $setting = Setting::all()->keyBy('key');
57: }
58: return $setting['favicon']->value;
59: }
60: /**
61: * @return int
62: */
63: function getLogInUserId()
64: {
65: return Auth::user()->id;
66: }
67: /**
68: * @return mixed
69: */
70: function getStates($countryId)
71: {
72: return State::where('country_id', $countryId)->toBase()->pluck('name',
'id')->toArray();
73: }
74: /**
75: * @return mixed
76: */
77: function getCities($stateId)
78: {
79: return City::where('state_id', $stateId)->pluck('name', 'id')->toArray();
80: }
81: /**
82: * @return string
83: */
84: function getDashboardURL()
85: {
86: if (Auth::user()->hasRole('clinic_admin')) {
87: return 'admin/dashboard';
88: } else {
89: if (Auth::user()->hasRole('doctor')) {
90: return 'doctors/dashboard';
91: } else {
92: if (Auth::user()->hasRole('patient')) {
93: return 'patients/dashboard';
94: }
95: }
96: }
97: if (Auth::user() !== null) {
98: /** @var User $user */
99: $user = Auth::user();
100: $permissions = $user->getAllPermissions()->pluck('name')->toArray();
101: if (in_array('manage_admin_dashboard', $permissions, true)) {
102: return 'admin/dashboard';
103: }
104: if (in_array('manage_doctors', $permissions, true)) {
105: return 'admin/doctors';
106: }
107: if (in_array('manage_patients', $permissions, true)) {
108: return 'admin/patients';
109: }
110: if (in_array('manage_staff', $permissions, true)) {
111: return 'admin/staff';
112: }
113: if (in_array('manage_appointments', $permissions, true)) {
114: return 'admin/appointments';
115: }
116: if (in_array('manage_patient_visits', $permissions, true)) {
117: return 'admin/visits';
118: }
119: if (in_array('manage_settings', $permissions, true)) {
120: return 'admin/settings';
121: }
122: if (in_array('manage_specialities', $permissions, true)) {
123: return 'admin/specializations';
124: }
125: if (in_array('manage_services', $permissions, true)) {
126: return 'admin/services';
127: }
128: if (in_array('manage_front_cms', $permissions, true)) {
129: return 'admin/cms';
130: }
131: if (in_array('manage_transactions', $permissions, true)) {
132: return 'admin/transactions';
133: }
134: }
135: return RouteServiceProvider::HOME;
136: }
137: /**
138: * @return string
139: */
140: function getDoctorSessionURL()
141: {
142: if (Auth::user()->hasRole('clinic_admin')) {
143: return 'admin/doctor-sessions';
144: } elseif (Auth::user()->hasRole('doctor')) {
145: return 'doctors/doctor-sessions';
146: } elseif (Auth::user()->hasRole('patient')) {
147: return 'patients/doctor-sessions';
148: }
149: return RouteServiceProvider::HOME;
150: }
151: function getDoctorSessionTime($doctor_id)
152: {
153: $doctorSession = DoctorSession::whereDoctorId($doctor_id)->get();
154: }
155: function getSlotByGap($startTime, $endTime)
156: {
157: $period = new CarbonPeriod($startTime, '15 minutes',
158: $endTime); // for create use 24 hours format later change format
159: $slots = [];
160: foreach ($period as $item) {
161: $slots[$item->format('h:i A')] = $item->format('h:i A');
162: }
163: return $slots;
164: }
165: function getSchedulesTimingSlot()
166: {
167: $period = new CarbonPeriod('00:00', '15 minutes', '24:00'); // for create use 24
hours
168: format later change format
169: $slots = [];
170: foreach ($period as $item) {
171: $slots[$item->format('h:i A')] = $item->format('h:i A');
172: }
173: return $slots;
174: }
175: /**
176: * @return string
177: */
178: function getBadgeColor($index)
179: {
180: $colors = [
181: 'primary',
182: 'danger',
183: 'success',
184: 'info',
185: 'warning',
186: 'dark',
187: ];
188: $index = $index % 6;
189: if (Auth::user()->dark_mode) {
190: array_splice($colors, 5, 1);
191: array_push($colors, 'bg-white');
192: }
193: return $colors[$index];
194: }
195: /**
196: * @return string
197: */
198: function getBadgeStatusColor($status)
199: {
200: $colors = [
201: 'danger',
202: 'primary',
203: 'success',
204: 'warning',
205: 'danger',
206: ];
207: return $colors[$status];
208: }
209: function getLoginDoctorSessionUrl(): string
210: {
211: return DoctorSession::toBase()->whereDoctorId(getLogInUser()->doctor->id)->exists()
?
212: route('doctors.doctor.schedule.edit') : route('doctors.doctor-sessions.create');
213: }
214: function doctorSessionActiveUrl(): string
215: {
216: return DoctorSession::toBase()->whereDoctorId(getLogInUser()->doctor->id)->exists()
?
217: 'doctors/doctor-schedule-edit*' : 'doctors/doctor-sessions/create*';
218: }
219: /**
220: * @return string
221: */
222: function getStatusBadgeColor($index)
223: {
224: $colors = [
225: 'danger',
226: 'primary',
227: 'success',
228: 'warning',
229: ];
230: $index = $index % 4;
231: return $colors[$index];
232: }
233: /**
234: * @return string
235: */
236: function getStatusColor($index)
237: {
238: $colors = [
239: '#F46387',
240: '#399EF7',
241: '#50CD89',
242: '#FAC702',
243: ];
244: $index = $index % 4;
245: return $colors[$index];
246: }
247: /**
248: * @return string
249: */
250: function getStatusClassName($status)
251: {
252: $classNames = [
253: 'bg-status-canceled',
254: 'bg-status-booked',
255: 'bg-status-checkIn',
256: 'bg-status-checkOut',
257: ];
258: $index = $status % 4;
259: return $classNames[$index];
260: }
261: /**
262: * @return mixed
263: */
264: function getSettingValue($key)
265: {
266: static $setting;
267: if (empty($setting)) {
268: $setting = Setting::all()->keyBy('key');
269: }
270: return $setting[$key]->value;
271: }
272: /**
273: * @return string
274: */
275: function setEmailLowerCase($email)
276: {
277: return strtolower($email);
278: }
279: /**
280: * @return string[]
281: */
282: function getUserLanguages()
283: {
284: $language = User::LANGUAGES;
285: asort($language);
286: return $language;
287: }
288: /**
289: * @return mixed
290: */
291: function getCurrencyIcon()
292: {
293: static $setting;
294: if (empty($setting)) {
295: $setting = Setting::all()->keyBy('key');
296: }
297: static $currencies;
298: if (empty($currencies)) {
299: $currencies = Currency::all()->keyBy('id');
300: }
301: $currencyId = $setting['currency']->value;
302: $currency = $currencies[$currencyId];
303: $currencyIcon = $currency->currency_icon ?? '$';
304: return $currencyIcon;
305: }
306: function setStripeApiKey()
307: {
308: Stripe::setApiKey(config('services.stripe.secret_key'));
309: }
310: /**
311: * @return HigherOrderBuilderProxy|mixed|string
312: */
313: function getCurrencyCode()
314: {
315: static $setting;
316: if (empty($setting)) {
317: $setting = Setting::all()->keyBy('key');
318: }
319: $currencyId = $setting['currency'];
320: $currencies = Cache::get('currency', null);
321: if (empty($currencies)) {
322: $currency = Currency::find($currencyId)->first();
323: Cache::put('currency', $currency);
324: return $currency->currency_code;
325: }
326: return $currencies->currency_code;
327: }
328: function version()
329: {
330: if (config('app.is_version') == 'true') {
331: $composerFile = file_get_contents('../composer.json');
332: $composerData = json_decode($composerFile, true);
333: $currentVersion = $composerData['version'];
334: return 'v'.$currentVersion;
335: }
336: }
337: if (! function_exists('getNotification')) {
338: function getNotification()
339: {
340: return Notification::whereReadAt(null)->where('user_id',
341: getLogInUserId())->orderByDesc('created_at')->get();
342: }
343: }
344: function getNotificationIcon($notificationFor)
345: {
346: switch ($notificationFor) {
347: case $notificationFor == Notification::CHECKOUT:
348: return 'fas fa-check-square';
349: case $notificationFor == Notification::PAYMENT_DONE:
350: return 'fas fa-money-bill-wave';
351: case $notificationFor == Notification::BOOKED:
352: return 'fas fa-calendar-alt';
353: case $notificationFor == Notification::CANCELED:
354: return 'fas fa-calendar-times';
355: case $notificationFor == Notification::REVIEW:
356: return 'fas fa-star';
357: case $notificationFor == Notification::LIVE_CONSULTATION:
358: return 'fas fa-video';
359: }
360: }
361: /**
362: * @return mixed|null
363: */
364: function checkLanguageSession()
365: {
366: if (Session::has('languageName')) {
367: return Session::get('languageName');
368: } else {
369: $user = getLogInUser();
370: if ($user != null) {
371: return $user->language;
372: }
373: }
374: return 'en';
375: }
376: /**
377: * @return mixed|null
378: */
379: function getCurrentLanguageName()
380: {
381: return User::LANGUAGES[checkLanguageSession()];
382: }
383: function getMonth()
384: {
385: $months = [
386: 1 => 'Jan', 2 => 'Feb', 3 => 'Mar', 4 => 'Apr', 5 => 'May', 6 => 'Jun', 7 => 'Jul',
8 =>
387: 'Aug', 9 => 'Sep',
388: 10 => 'Oct', 11 => 'Nov', 12 => 'Dec',
389: ];
390: return $months;
391: }
392: /**
393: * @return string[]
394: */
395: function getAllPaymentStatus()
396: {
397: $paymentGateway = \App\Models\Appointment::PAYMENT_METHOD;
398: $selectedPaymentGateway = PaymentGateway::pluck('payment_gateway',
399: 'payment_gateway_id')->toArray();
400: $paymentMethodToReturn = array_intersect($paymentGateway, $selectedPaymentGateway);
401: return $paymentMethodToReturn;
402: }
403: /**
404: * @return string[]
405: */
406: function getPaymentGateway()
407: {
408: $paymentGateway = \App\Models\Appointment::PAYMENT_GATEWAY;
409: $selectedPaymentGateway = PaymentGateway::pluck('payment_gateway')->toArray();
410: $paymentGatewayToReturn = array_intersect($paymentGateway, $selectedPaymentGateway);
411: return $paymentGatewayToReturn;
412: }
413: function getWeekDate(): string
414: {
415: $date = Carbon::now();
416: $startOfWeek = $date->startOfWeek()->subDays(1);
417: $startDate = $startOfWeek->format('Y-m-d');
418: $endOfWeek = $startOfWeek->addDays(6);
419: $endDate = $endOfWeek->format('Y-m-d');
420: return $startDate.' - '.$endDate;
421: }
422: function getCurrencyFormat($currencies, $amount): string
423: {
424: return moneyFormat($amount, $currencies);
425: }
426: function filterLangChange($filterArray): array
427: {
428: foreach ($filterArray as $key => $value) {
429: $array[$key] = __('messages.filter.'.strtolower($value));
430: }
431: return $array;
432: }
433: function paymentMethodLangChange($paymentMethodNameArray): array
434: {
435: $array = [];
436: foreach ($paymentMethodNameArray as $key => $value) {
437: $array[$key] = __('messages.payment_method.'.strtolower($value));
438: }
439: return $array;
440: }
441: function zeroDecimalCurrencies(): array
442: {
443: return [
444: 'BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND',
'VUV',
445: 'XAF', 'XOF', 'XPF',
446: ];
447: }
448: /**
449: * @param array $models
450: * @param string $columnName
451: * @param int $id
452: * @return bool
453: */
454: function canDelete($models, $columnName, $id)
455: {
456: foreach ($models as $model) {
457: $result = $model::where($columnName, $id)->exists();
458: if ($result) {
459: return true;
460: }
461: }
462: return false;
463: }
464: /**
465: * @param array $input
466: * @param string $key
467: * @return string|null
468: */
469: function preparePhoneNumber($input, $key)
470: {
471: return (! empty($input[$key])) ? '+'.$input['region_code'].$input[$key] : null;
472: }
473: /**
474: * @return mixed
475: */
476: function getCurrentCurrency()
477: {
478: /** @var Setting $currentCurrency */
479: static $currentCurrency;
480: if (empty($currentCurrency)) {
481: $currentCurrency = Setting::where('key', 'currency')->first();
482: }
483: return $currentCurrency->value;
484: }
485: /**
486: * @return mixed
487: */
488: function getCurrentLoginUserLanguageName()
489: {
490: return Auth::user()->language;
491: }
492: function generateUniquePurchaseNumber()
493: {
494: do {
495: $code = random_int(100000, 999999);
496: } while (\App\Models\PurchaseMedicine::where('purchase_no', '=', $code)->first());
497: return $code;
498: }
499: function getPatientUniqueId()
500: {
501: return mb_strtoupper(Patient::generatePatientUniqueId());
502: }
503: function generateUniqueBillNumber()
504: {
505: do {
506: $code = random_int(1000, 9999);
507: } while (\App\Models\MedicineBill::where('bill_number', '=', $code)->first());
508: return $code;
509: }
510: function getAmountToWord(float $amount): string
511: {
512: $amount_after_decimal = round($amount - ($num = floor($amount)), 2);
513: $count_length = strlen($num);
514: $x = 0;
515: $string = [];
516: $change_words = [
517: 0 => '', 1 => 'One', 2 => 'Two',
518: 3 => 'Three', 4 => 'Four', 5 => 'Five', 6 => 'Six',
519: 7 => 'Seven', 8 => 'Eight', 9 => 'Nine',
520: 10 => 'Ten', 11 => 'Eleven', 12 => 'Twelve',
521: 13 => 'Thirteen', 14 => 'Fourteen', 15 => 'Fifteen',
522: 16 => 'Sixteen', 17 => 'Seventeen', 18 => 'Eighteen',
523: 19 => 'Nineteen', 20 => 'Twenty', 30 => 'Thirty',
524: 40 => 'Forty', 50 => 'Fifty', 60 => 'Sixty',
525: 70 => 'Seventy', 80 => 'Eighty', 90 => 'Ninety',
526: ];
527: $here_digits = ['', 'Hundred', 'Thousand', 'Lakh', 'Crore'];
528: while ($x < $count_length) {
529: $get_divider = ($x == 2) ? 10 : 100;
530: $amount = floor($num % $get_divider);
531: $num = floor($num / $get_divider);
532: $x += $get_divider == 10 ? 1 : 2;
533: if ($amount) {
534: $add_plural = (($counter = count($string)) && $amount > 9) ? 's' : null;
535: $amt_hundred = ($counter == 1 && $string[0]) ? ' and ' : null;
536: $string[] = ($amount < 21) ? $change_words[$amount].'
537: '.$here_digits[$counter].$add_plural.'
538: '.$amt_hundred : $change_words[floor($amount / 10)].' '.$change_words[$amount %
10].'
539: '.$here_digits[$counter].$add_plural.' '.$amt_hundred;
540: } else {
541: $string[] = null;
542: }
543: }
544: $implode_to_Rupees = implode('', array_reverse($string));
545: $get_paise = ($amount_after_decimal > 0) ? 'And
'.($change_words[$amount_after_decimal /
546: 10].'
547: '.$change_words[$amount_after_decimal % 10]).' Paise' : '';
548: return ($implode_to_Rupees ? $implode_to_Rupees.getCurrencyCode() : '').$get_paise;
549: }
550: /**
551: * @return bool
552: */
553: function canAccessRecord($model, $id)
554: {
555: $recordExists = $model::where('id', $id)->exists();
556: if ($recordExists) {
557: return true;
558: }
559: return false;
560: }
561: /**
562: * @return bool
563: */
564: function getLoggedinDoctor()
565: {
566: return Auth::user()->hasRole(['Doctor']);
567: }
568: function isRole(string $role)
569: {
570: if (getLogInUser()->hasRole($role)) {
571: return true;
572: }
573: return false;
574: }
575: function isZoomTokenExpire()
576: {
577: $isExpired = false;
578: $zoomOAuth = ZoomOAuth::where('user_id', Auth::id())->first();
579: $currentTime = Carbon::now();
580: $isExpired = is_null($zoomOAuth) == true ? true : $isExpired;
581: if (! is_null($zoomOAuth) && $zoomOAuth->updated_at < $currentTime->subMinutes(57))
{
582: $isExpired = true;
583: }
584: return $isExpired;
585: }
[app > Console > Kernel.php]
1: <?php
2: namespace App\Console;
3: use Illuminate\Console\Scheduling\Schedule;
4: use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
5: class Kernel extends ConsoleKernel
6: {
7: /**
8: * Define the application's command schedule.
9: */
10: protected function schedule(Schedule $schedule): void
11: {
12: //
13: }
14: /**
15: * Register the commands for the application.
16: */
17: protected function commands(): void
18: {
19: $this->load(__DIR__.'/Commands');
20: require base_path('routes/console.php');
21: }
22: }
[app > Events > CreateGoogleAppointment.php]
1: <?php
2: namespace App\Events;
3: use Illuminate\Broadcasting\InteractsWithSockets;
4: use Illuminate\Foundation\Events\Dispatchable;
5: use Illuminate\Queue\SerializesModels;
6: class CreateGoogleAppointment
7: {
8: use Dispatchable, InteractsWithSockets, SerializesModels;
9: public $forPatient;
10: public $appointmentID;
11: /**
12: * Create a new event instance.
13: *
14: * @return void
15: */
16: public function __construct($forPatient, $appointmentID)
17: {
18: $this->forPatient = $forPatient;
19: $this->appointmentID = $appointmentID;
20: }
21: }
[app > Events > DeleteAppointmentFromGoogleCalendar.php]
1: <?php
2: namespace App\Events;
3: use Illuminate\Broadcasting\InteractsWithSockets;
4: use Illuminate\Foundation\Events\Dispatchable;
5: use Illuminate\Queue\SerializesModels;
6: class DeleteAppointmentFromGoogleCalendar
7: {
8: use Dispatchable, InteractsWithSockets, SerializesModels;
9: public $user;
10: public $events;
11: /**
12: * Create a new event instance.
13: */
14: public function __construct($events, $user)
15: {
16: $this->events = $events;
17: $this->user = $user;
18: }
19: }
[app > Exceptions > Handler.php]
1: <?php
2: namespace App\Exceptions;
3: use Illuminate\Database\Eloquent\ModelNotFoundException;
4: use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
5: use Illuminate\Support\Facades\Redirect;
6: use Illuminate\Support\Facades\Response;
7: use Illuminate\Validation\ValidationException;
8: use Throwable;
9: class Handler extends ExceptionHandler
10: {
11: /**
12: * A list of the inputs that are never flashed for validation exceptions.
13: *
14: * @var array
15: */
16: protected $dontFlash = [
17: 'current_password',
18: 'password',
19: 'password_confirmation',
20: ];
21: /**
22: * Register the exception handling callbacks for the application.
23: */
24: public function register(): void
25: {
26: $this->reportable(function (Throwable $e) {
27: //
28: });
29: }
30: public function render($request, Throwable $exception)
31: {
32: $code = $exception->getCode();
33: $message = $exception->getMessage();
34: if ($code < 100 || $code >= 600) {
35: $code = \Illuminate\Http\Response::HTTP_INTERNAL_SERVER_ERROR;
36: }
37: if ($exception instanceof ModelNotFoundException) {
38: $message = $exception->getMessage();
39: $code = \Illuminate\Http\Response::HTTP_NOT_FOUND;
40: if (preg_match('@\\\\(\w+)\]@', $message, $matches)) {
41: $model = $matches[1];
42: $model = preg_replace('/Table/i', '', $model);
43: $message = "{$model} not found.";
44: }
45: }
46: if ($exception instanceof ValidationException) {
47: $validator = $exception->validator;
48: $message = $validator->errors()->first();
49: $code = \Illuminate\Http\Response::HTTP_UNPROCESSABLE_ENTITY;
50: if (! $request->expectsJson() and ! $request->isXmlHttpRequest()) {
51: return Redirect::back()->withInput()->withErrors($message);
52: }
53: }
54: if ($request->expectsJson() or $request->isXmlHttpRequest()) {
55: return Response::json([
56: 'success' => false,
57: 'message' => $message,
58: ], $code);
59: }
60: return parent::render($request, $exception);
61: }
62: }
[app > Exports > PurchaseMedicineExport.php]
1: <?php
2: namespace App\Exports;
3: use App\Models\PurchaseMedicine;
4: use Illuminate\Contracts\View\View;
5: use Maatwebsite\Excel\Concerns\FromView;
6: use Maatwebsite\Excel\Concerns\ShouldAutoSize;
7: use Maatwebsite\Excel\Concerns\WithEvents;
8: use Maatwebsite\Excel\Concerns\WithTitle;
9: use Maatwebsite\Excel\Events\AfterSheet;
10: class PurchaseMedicineExport implements FromView, WithTitle, ShouldAutoSize,
WithEvents
11: {
12: public function view(): View
13: {
14: return view('purchase-medicines.purchase-medicine', ['purchaseMedicines' =>
15: PurchaseMedicine::with('purchasedMedcines')->get()]);
16: }
17: public function title(): string
18: {
19: return 'Purchase Medicine';
20: }
21: public function registerEvents(): array
22: {
23: return [
24: AfterSheet::class => function (AfterSheet $event) {
25: $cellRange = 'A1:W1'; // All headers
26: $event->sheet->getDelegate()->getStyle($cellRange)->getFont()->setSize(14);
27: },
28: ];
29: }
30: }
[app > Http > Kernel.php]
1: <?php
2: namespace App\Http;
3: use App\Http\Middleware\Authenticate;
4: use App\Http\Middleware\checkImpersonateUser;
5: use App\Http\Middleware\CheckUserStatus;
6: use App\Http\Middleware\EncryptCookies;
7: use App\Http\Middleware\PreventRequestsDuringMaintenance;
8: use App\Http\Middleware\RedirectIfAuthenticated;
9: use App\Http\Middleware\SetLanguage;
10: use App\Http\Middleware\TrimStrings;
11: use App\Http\Middleware\TrustProxies;
12: use App\Http\Middleware\VerifyCsrfToken;
13: use App\Http\Middleware\XSS;
14: use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
15: use Illuminate\Auth\Middleware\Authorize;
16: use Illuminate\Auth\Middleware\EnsureEmailIsVerified;
17: use Illuminate\Auth\Middleware\RequirePassword;
18: use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
19: use Illuminate\Foundation\Http\Kernel as HttpKernel;
20: use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
21: use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
22: use Illuminate\Http\Middleware\HandleCors;
23: use Illuminate\Http\Middleware\SetCacheHeaders;
24: use Illuminate\Routing\Middleware\SubstituteBindings;
25: use Illuminate\Routing\Middleware\ThrottleRequests;
26: use Illuminate\Routing\Middleware\ValidateSignature;
27: use Illuminate\Session\Middleware\StartSession;
28: use Illuminate\View\Middleware\ShareErrorsFromSession;
29: use Spatie\Permission\Middlewares\PermissionMiddleware;
30: use Spatie\Permission\Middlewares\RoleMiddleware;
31: class Kernel extends HttpKernel
32: {
33: /**
34: * The application's global HTTP middleware stack.
35: *
36: * These middleware are run during every request to your application.
37: *
38: * @var array
39: */
40: protected $middleware = [
41: TrustProxies::class,
42: HandleCors::class,
43: PreventRequestsDuringMaintenance::class,
44: ValidatePostSize::class,
45: TrimStrings::class,
46: ConvertEmptyStringsToNull::class,
47: ];
48: /**
49: * The application's route middleware groups.
50: *
51: * @var array
52: */
53: protected $middlewareGroups = [
54: 'web' => [
55: EncryptCookies::class,
56: AddQueuedCookiesToResponse::class,
57: StartSession::class,
58: ShareErrorsFromSession::class,
59: VerifyCsrfToken::class,
60: SubstituteBindings::class,
61: ],
62: 'api' => [
63: \Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
64: SubstituteBindings::class,
65: ],
66: ];
67: /**
68: * The application's middleware aliases.
69: *
70: * Aliases may be used to conveniently assign middleware to routes and groups.
71: *
72: * @var array
73: */
74: protected $middlewareAliases = [
75: 'auth' => Authenticate::class,
76: 'auth.basic' => AuthenticateWithBasicAuth::class,
77: 'cache.headers' => SetCacheHeaders::class,
78: 'can' => Authorize::class,
79: 'guest' => RedirectIfAuthenticated::class,
80: 'password.confirm' => RequirePassword::class,
81: 'precognitive' =>
82: \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
83: 'signed' => ValidateSignature::class,
84: 'throttle' => ThrottleRequests::class,
85: 'verified' => EnsureEmailIsVerified::class,
86: 'role' => RoleMiddleware::class,
87: 'permission' => PermissionMiddleware::class,
88: 'checkUserStatus' => CheckUserStatus::class,
89: 'xss' => XSS::class,
90: 'checkImpersonateUser' => checkImpersonateUser::class,
91: 'setLanguage' => SetLanguage::class,
92: ];
93: }
[Http > Controllers > AppBaseController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Utils\ResponseUtil;
4: use Illuminate\Http\JsonResponse;
5: use Response;
6: /**
7: * @SWG\Swagger(
8: * basePath="/api/v1",
9: *
10: * @SWG\Info(
11: * title="Laravel Generator APIs",
12: * version="1.0.0",
13: * )
14: * )
15: * This class should be parent class for other API controllers
16: * Class AppBaseController
17: */
18: class AppBaseController extends Controller
19: {
20: public function sendResponse($result, $message): JsonResponse
21: {
22: return Response::json(ResponseUtil::makeResponse($message, $result));
23: }
24: public function sendError($error, $code = 422): JsonResponse
25: {
26: return Response::json(ResponseUtil::makeError($error), $code);
27: }
28: public function sendSuccess($message): JsonResponse
29: {
30: return Response::json([
31: 'success' => true,
32: 'message' => $message,
33: ], 200);
34: }
35: }
[Http > Controllers > AppointmentController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Events\DeleteAppointmentFromGoogleCalendar;
4: use App\Http\Requests\CreateAppointmentRequest;
5: use App\Http\Requests\CreateFrontAppointmentRequest;
6: use App\Models\Appointment;
7: use App\Models\Doctor;
8: use App\Models\Notification;
9: use App\Models\Patient;
10: use App\Models\Service;
11: use App\Models\Transaction;
12: use App\Models\User;
13: use App\Models\UserGoogleAppointment;
14: use App\Repositories\AppointmentRepository;
15: use App\Repositories\GoogleCalendarRepository;
16: use \PDF;
17: use Carbon\Carbon;
18: use Exception;
19: use Flash;
20: use Illuminate\Contracts\Foundation\Application;
21: use Illuminate\Contracts\View\Factory;
22: use Illuminate\Contracts\View\View;
23: use Illuminate\Database\Eloquent\HigherOrderBuilderProxy;
24: use Illuminate\Http\JsonResponse;
25: use Illuminate\Http\RedirectResponse;
26: use Illuminate\Http\Request;
27: use Illuminate\Routing\Redirector;
28: use Illuminate\Support\Arr;
29: use Illuminate\Support\Facades\App;
30: use Illuminate\Support\Facades\Crypt;
31: use Illuminate\Support\Facades\Storage;
32: use Illuminate\Support\Str;
33: use Stripe\Exception\ApiErrorException;
34: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
35: class AppointmentController extends AppBaseController
36: {
37: /** @var AppointmentRepository */
38: private $appointmentRepository;
39: public function __construct(AppointmentRepository $appointmentRepo)
40: {
41: $this->appointmentRepository = $appointmentRepo;
42: }
43: /**
44: * @return Application|Factory|View
45: */
46: public function index(): \Illuminate\View\View
47: {
48: $allPaymentStatus = getAllPaymentStatus();
49: $paymentStatus = Arr::except($allPaymentStatus, [Appointment::MANUALLY]);
50: $paymentGateway = getPaymentGateway();
51: return view('appointments.index', compact('allPaymentStatus', 'paymentGateway',
52: 'paymentStatus'));
53: }
54: /**
55: * Show the form for creating a new Appointment.
56: *
57: * @return Application|Factory|View
58: */
59: public function create(): \Illuminate\View\View
60: {
61: $data = $this->appointmentRepository->getData();
62: return view('appointments.create', compact('data'));
63: }
64: /**
65: * @throws ApiErrorException
66: */
67: public function store(CreateAppointmentRequest $request): JsonResponse
68: {
69: $input = $request->all();
70: $appointment = $this->appointmentRepository->store($input);
71: if ($input['payment_type'] == Appointment::STRIPE) {
72: $result = $this->appointmentRepository->createSession($appointment);
73: return $this->sendResponse([
74: 'appointmentId' => $appointment->id,
75: 'payment_type' => $input['payment_type'],
76: $result,
77: ], 'Stripe '.__('messages.appointment.session_created_successfully'));
78: }
79: if ($input['payment_type'] == Appointment::PAYSTACK) {
80: if ($request->isXmlHttpRequest()) {
81: return $this->sendResponse([
82: 'redirect_url' => route('paystack.init', ['appointmentData' => $appointment]),
83: 'payment_type' => $input['payment_type'],
84: 'appointmentId' => $appointment->id,
85: ], 'Paystack '.__('messages.appointment.session_created_successfully'));
86: }
87: return redirect(route('paystack.init'));
88: }
89: if ($input['payment_type'] == Appointment::PAYPAL) {
90: if ($request->isXmlHttpRequest()) {
91: return $this->sendResponse([
92: 'redirect_url' => route('paypal.index', ['appointmentData' => $appointment]),
93: 'payment_type' => $input['payment_type'],
94: 'appointmentId' => $appointment->id,
95: ], 'Paypal '.__('messages.appointment.session_created_successfully'));
96: }
97: return redirect(route('paypal.init'));
98: }
99: if ($input['payment_type'] == Appointment::RAZORPAY) {
100: return $this->sendResponse([
101: 'payment_type' => $input['payment_type'],
102: 'appointmentId' => $appointment->id,
103: ], 'Razorpay '.__('messages.appointment.session_created_successfully'));
104: }
105: if ($input['payment_type'] == Appointment::AUTHORIZE) {
106: return $this->sendResponse([
107: 'payment_type' => $input['payment_type'],
108: 'appointmentId' => $appointment->id,
109: ], 'Authorize '.__('messages.appointment.session_created_successfully'));
110: }
111: if ($input['payment_type'] == Appointment::PAYTM) {
112: return $this->sendResponse([
113: 'payment_type' => $input['payment_type'],
114: 'appointmentId' => $appointment->id,
115: ], 'Paytm '.__('messages.appointment.session_created_successfully'));
116: }
117: $url = route('appointments.index');
118: if (getLogInUser()->hasRole('patient')) {
119: $url = route('patients.patient-appointments-index');
120: }
121: $data = [
122: 'url' => $url,
123: 'payment_type' => $input['payment_type'],
124: 'appointmentId' => $appointment->id,
125: ];
126: return $this->sendResponse($data, __('messages.flash.appointment_create'));
127: }
128: /**
129: * Display the specified Appointment.
130: *
131: * @return Application|RedirectResponse|Redirector
132: */
133: public function show(Appointment $appointment)
134: {
135: $allPaymentStatus = getAllPaymentStatus();
136: if (getLogInUser()->hasRole('doctor')) {
137: $doctor =
138: Appointment::whereId($appointment->id)->whereDoctorId(getLogInUser()->doctor->id);
139: if (! $doctor->exists()) {
140: return redirect()->back();
141: }
142: } elseif (getLogInUser()->hasRole('patient')) {
143: $patient =
144: Appointment::whereId($appointment->id)->wherePatientId(getLogInUser()->patient->id);
145: if (! $patient->exists()) {
146: return redirect()->back();
147: }
148: }
149: $appointment = $this->appointmentRepository->showAppointment($appointment);
150: if (empty($appointment)) {
151: Flash::error(__('messages.flash.appointment_not_found'));
152: if (getLogInUser()->hasRole('patient')) {
153: return redirect(route('patients.patient-appointments-index'));
154: } else {
155: return redirect(route('admin.appointments.index'));
156: }
157: }
158: if (getLogInUser()->hasRole('patient')) {
159: return view('patient_appointments.show')->with('appointment', $appointment);
160: } else {
161: return view('appointments.show')->with('appointment', $appointment)
162: ->with('allPaymentStatus',$allPaymentStatus)
163: ->with([
164: 'paid' => Appointment::PAID,
165: 'pending' => Appointment::PENDING,
166: ])
167: ->with([
168: 'all' => Appointment::ALL,
169: 'book' => Appointment::BOOKED,
170: 'checkIn' => Appointment::CHECK_IN,
171: 'checkOut' => Appointment::CHECK_OUT,
172: 'cancel' => Appointment::CANCELLED,
173: ]);
174: }
175: }
176: /**
177: * Remove the specified Appointment from storage.
178: */
179: public function destroy(Appointment $appointment): JsonResponse
180: {
181: if (getLogInUser()->hasrole('patient')) {
182: if ($appointment->patient_id !== getLogInUser()->patient->id) {
183: return $this->sendError('Seems, you are not allowed to access this record.');
184: }
185: }
186: $appointmentUniqueId = $appointment->appointment_unique_id;
187: $transaction = Transaction::whereAppointmentId($appointmentUniqueId)->first();
188: if ($transaction) {
189: $transaction->delete();
190: }
191: $appointment->delete();
192: return $this->sendSuccess(__('messages.flash.appointment_delete'));
193: }
194: /**
195: * @return Application|Factory|View
196: *
197: * @throws Exception
198: */
199: public function doctorAppointment(Request $request): \Illuminate\View\View
200: {
201: $appointmentStatus = Appointment::ALL_STATUS;
202: $paymentStatus = getAllPaymentStatus();
203: return view('doctor_appointment.index', compact('appointmentStatus',
'paymentStatus'));
204: }
205: /**
206: * @return Application|Factory|View|JsonResponse
207: */
208: public function doctorAppointmentCalendar(Request $request)
209: {
210: if ($request->ajax()) {
211: $input = $request->all();
212: $data = $this->appointmentRepository->getAppointmentsData();
213: return $this->sendResponse($data, __('messages.flash.doctor_appointment'));
214: }
215: return view('doctor_appointment.calendar');
216: }
217: /**
218: * @return Application|Factory|View
219: */
220: public function patientAppointmentCalendar(Request $request)
221: {
222: if ($request->ajax()) {
223: $input = $request->all();
224: $data = $this->appointmentRepository->getPatientAppointmentsCalendar();
225: return $this->sendResponse($data, __('messages.flash.patient_appointment'));
226: }
227: return view('appointments.patient-calendar');
228: }
229: /**
230: * @return Application|Factory|View|JsonResponse
231: */
232: public function appointmentCalendar(Request $request)
233: {
234: if ($request->ajax()) {
235: $input = $request->all();
236: $data = $this->appointmentRepository->getCalendar();
237: return $this->sendResponse($data, __('messages.flash.appointment_retrieve'));
238: }
239: return view('appointments.calendar');
240: }
241: /**
242: * @return Application|Factory|View
243: */
244: public function appointmentDetail(Appointment $appointment): \Illuminate\View\View
245: {
246: //not complate query optimize
247: $appointment = $this->appointmentRepository->showDoctorAppointment($appointment);
248: return view('doctor_appointment.show', compact('appointment'));
249: }
250: /**
251: * @return mixed
252: */
253: public function changeStatus(Request $request)
254: {
255: $input = $request->all();
256: if (getLogInUser()->hasRole('doctor')) {
257: $doctor =
258: Appointment::whereId($input['appointmentId'])->whereDoctorId(getLogInUser()->doctor-
>id);
259: if (! $doctor->exists()) {
260: return $this->sendError(__('messages.common.not_allow__assess_record'));
261: }
262: }
263: $appointment = Appointment::findOrFail($input['appointmentId']);
264: $appointment->update([
265: 'status' => $input['appointmentStatus'],
266: ]);
267: $fullTime = $appointment->from_time.''.$appointment->from_time_type.' -
268: '.$appointment->to_time.''.$appointment->to_time_type.' '.'
269: '.Carbon::parse($appointment->date)->format('jS M, Y');
270: // $patient = Patient::whereId($appointment->patient_id)->with('user')->first();
271: $patient = Patient::whereId($appointment->patient_id)->with('user')->first();
272: $doctor = Doctor::whereId($appointment->doctor_id)->with('user')->first();
273: if ($input['appointmentStatus'] == Appointment::CHECK_OUT) {
274: Notification::create([
275: 'title' => Notification::APPOINTMENT_CHECKOUT_PATIENT_MSG.'
'.getLogInUser()->full_name,
276: 'type' => Notification::CHECKOUT,
277: 'user_id' => $patient->user_id,
278: ]);
279: Notification::create([
280: 'title' => $patient->user->full_name.'\'s appointment check out by
281: '.getLogInUser()->full_name.' at '.$fullTime,
282: 'type' => Notification::CHECKOUT,
283: 'user_id' => $doctor->user_id,
284: ]);
285: } elseif ($input['appointmentStatus'] == Appointment::CANCELLED) {
286: $events = UserGoogleAppointment::with(['user'])->where('appointment_id',
287: $appointment->id)->get();
288: /** @var GoogleCalendarRepository $repo */
289: $repo = App::make(GoogleCalendarRepository::class);
290: $repo->destroy($events);
291: Notification::create([
292: 'title' => Notification::APPOINTMENT_CANCEL_PATIENT_MSG.'
'.getLogInUser()->full_name,
293: 'type' => Notification::CANCELED,
294: 'user_id' => $patient->user_id,
295: ]);
296: Notification::create([
297: 'title' => $patient->user->full_name.'\'s appointment cancelled
298: by'.getLogInUser()->full_name.' at '.$fullTime,
299: 'type' => Notification::CANCELED,
300: 'user_id' => $doctor->user_id,
301: ]);
302: }
303: return $this->sendSuccess(__('messages.flash.status_update'));
304: }
305: /**
306: * @return mixed
307: */
308: public function cancelStatus(Request $request)
309: {
310: $appointment = Appointment::findOrFail($request['appointmentId']);
311: if ($appointment->patient_id !== getLogInUser()->patient->id) {
312: return $this->sendError(__('messages.common.not_allow__assess_record'));
313: }
314: $appointment->update([
315: 'status' => Appointment::CANCELLED,
316: ]);
317: $events = UserGoogleAppointment::with('user')
318: ->where('appointment_id', $appointment->id)
319: ->get()
320: ->groupBy('user_id');
321: foreach ($events as $userID => $event) {
322: $user = $event[0]->user;
323: DeleteAppointmentFromGoogleCalendar::dispatch($event, $user);
324: }
325: $fullTime = $appointment->from_time.''.$appointment->from_time_type.' -
326: '.$appointment->to_time.''.$appointment->to_time_type.' '.'
327: '.Carbon::parse($appointment->date)->format('jS M, Y');
328: $patient = Patient::whereId($appointment->patient_id)->with('user')->first();
329: $doctor = Doctor::whereId($appointment->doctor_id)->with('user')->first();
330: Notification::create([
331: 'title' => $patient->user->full_name.'
'.Notification::APPOINTMENT_CANCEL_DOCTOR_MSG.'
332: '.$fullTime,
333: 'type' => Notification::CANCELED,
334: 'user_id' => $doctor->user_id,
335: ]);
336: return $this->sendSuccess(__('messages.flash.appointment_cancel'));
337: }
338: /**
339: * @throws ApiErrorException
340: */
341: public function frontAppointmentBook(CreateFrontAppointmentRequest $request):
JsonResponse
342: {
343: app()->setLocale(checkLanguageSession());
344: $input = $request->all();
345: $appointment = $this->appointmentRepository->frontSideStore($input);
346: if ($input['payment_type'] == Appointment::STRIPE) {
347: $result = $this->appointmentRepository->createSession($appointment);
348: return $this->sendResponse([
349: 'payment_type' => $input['payment_type'],
350: $result,
351: ], 'Stripe '.__('messages.appointment.session_created_successfully'));
352: }
353: if ($input['payment_type'] == Appointment::PAYPAL) {
354: if ($request->isXmlHttpRequest()) {
355: return $this->sendResponse([
356: 'redirect_url' => route('paypal.index', ['appointmentData' => $appointment]),
357: 'payment_type' => $input['payment_type'],
358: 'appointmentId' => $appointment->id,
359: ], 'Paypal '.__('messages.appointment.session_created_successfully'));
360: }
361: }
362: if ($input['payment_type'] == Appointment::PAYSTACK) {
363: if ($request->isXmlHttpRequest()) {
364: return $this->sendResponse([
365: 'redirect_url' => route('paystack.init', ['appointmentData' => $appointment]),
366: 'payment_type' => $input['payment_type'],
367: ], 'Paystck '.__('messages.appointment.session_created_successfully'));
368: }
369: return redirect(route('paystack.init'));
370: }
371: if ($input['payment_type'] == Appointment::RAZORPAY) {
372: return $this->sendResponse([
373: 'payment_type' => $input['payment_type'],
374: 'appointmentId' => $appointment->id,
375: ], 'Razorpay '.__('messages.appointment.session_created_successfully'));
376: }
377: if ($input['payment_type'] == Appointment::PAYTM) {
378: return $this->sendResponse([
379: 'payment_type' => $input['payment_type'],
380: 'appointmentId' => $appointment->id,
381: ], 'Paytm '.__('messages.appointment.session_created_successfully'));
382: }
383: if ($input['payment_type'] == Appointment::AUTHORIZE) {
384: return $this->sendResponse([
385: 'payment_type' => $input['payment_type'],
386: 'appointmentId' => $appointment->id,
387: ], __('messages.appointment.authorize_session_created_successfully'));
388: }
389: $data['payment_type'] = $input['payment_type'];
390: $data['appointmentId'] = $appointment->id;
391: return $this->sendResponse($data, __('messages.flash.appointment_booked'));
392: }
393: public function frontHomeAppointmentBook(Request $request): RedirectResponse
394: {
395: $data = $request->all();
396: return redirect()->route('medicalAppointment')->with(['data' => $data]);
397: }
398: /**
399: * @return HigherOrderBuilderProxy|mixed|string
400: *
401: * @throws Exception
402: */
403: public function getPatientName(Request $request)
404: {
405: $checkRecord = User::whereEmail($request->email)->whereType(User::PATIENT)->first();
406: if ($checkRecord != '') {
407: return $this->sendResponse($checkRecord->full_name,
408: __('messages.appointment.patient_name_retrieved') );
409: }
410: return false;
411: }
412: /**
413: * @return Application|RedirectResponse|Redirector
414: *
415: * @throws ApiErrorException
416: */
417: public function paymentSuccess(Request $request): RedirectResponse
418: {
419: $sessionId = $request->get('session_id');
420: if (empty($sessionId)) {
421: throw new
422: UnprocessableEntityHttpException(__('messages.appointment.session_id_required'));
423: }
424: setStripeApiKey();
425: $sessionData = \Stripe\Checkout\Session::retrieve($sessionId);
426: $appointment =
427: Appointment::whereAppointmentUniqueId($sessionData->client_reference_id)->first();
428: $patientId =
429: User::whereEmail($sessionData->customer_details->email)->pluck('id')->first();
430: $transaction = [
431: 'user_id' => $patientId,
432: 'transaction_id' => $sessionData->id,
433: 'appointment_id' => $sessionData->client_reference_id,
434: 'amount' => intval($sessionData->amount_total / 100),
435: 'type' => Appointment::STRIPE,
436: 'meta' => $sessionData,
437: ];
438: Transaction::create($transaction);
439: $appointment->update([
440: 'payment_method' => Appointment::STRIPE,
441: 'payment_type' => Appointment::PAID,
442: ]);
443: Flash::success(__('messages.flash.appointment_created_payment_complete'));
444: $patient = Patient::whereUserId($patientId)->with('user')->first();
445: Notification::create([
446: 'title' => Notification::APPOINTMENT_PAYMENT_DONE_PATIENT_MSG,
447: 'type' => Notification::PAYMENT_DONE,
448: 'user_id' => $patient->user_id,
449: ]);
450: if (parse_url(url()->previous(), PHP_URL_PATH) == '/medical-appointment') {
451: return redirect(route('medicalAppointment'));
452: }
453: if (! getLogInUser()) {
454: return redirect(route('medical'));
455: }
456: if (getLogInUser()->hasRole('patient')) {
457: return redirect(route('patients.patient-appointments-index'));
458: }
459: return redirect(route('appointments.index'));
460: }
461: /**
462: * @return Application|RedirectResponse|Redirector
463: */
464: public function handleFailedPayment(): RedirectResponse
465: {
466: setStripeApiKey();
467: Flash::error(__('messages.flash.appointment_created_payment_not_complete'));
468: if (! getLogInUser()) {
469: return redirect(route('medicalAppointment'));
470: }
471: if (getLogInUser()->hasRole('patient')) {
472: return redirect(route('patients.patient-appointments-index'));
473: }
474: return redirect(route('appointments.index'));
475: }
476: /**
477: * @return mixed
478: *
479: * @throws ApiErrorException
480: */
481: public function appointmentPayment(Request $request)
482: {
483: $appointmentId = $request['appointmentId'];
484: $appointment = Appointment::whereId($appointmentId)->first();
485: $result = $this->appointmentRepository->createSession($appointment);
486: return $this->sendResponse($result,
487: __('messages.appointment.session_created_successfully'));
488: }
489: /**
490: * @return mixed
491: */
492: public function changePaymentStatus(Request $request)
493: {
494: $input = $request->all();
495: if (getLogInUser()->hasRole('doctor')) {
496: $doctor =
497: Appointment::whereId($input['appointmentId'])->whereDoctorId(getLogInUser()->doctor-
>id);
498: if (! $doctor->exists()) {
499: return $this->sendError(__('messages.common.not_allow__assess_record'));
500: }
501: }
502: $appointment = Appointment::with('patient')->findOrFail($input['appointmentId']);
503: $transactionExist =
504: Transaction::whereAppointmentId($appointment['appointment_unique_id'])->first();
505: $appointment->update([
506: 'payment_type' => $input['paymentStatus'],
507: 'payment_method' => $input['paymentMethod'],
508: ]);
509: if (empty($transactionExist)) {
510: $transaction = [
511: 'user_id' => $appointment->patient->user_id,
512: 'transaction_id' => Str::random(10),
513: 'appointment_id' => $appointment->appointment_unique_id,
514: 'amount' => $appointment->payable_amount,
515: 'type' => Appointment::MANUALLY,
516: 'status' => Transaction::SUCCESS,
517: 'accepted_by' => $input['loginUserId'],
518: ];
519: Transaction::create($transaction);
520: } else {
521: $transactionExist->update([
522: 'status' => Transaction::SUCCESS,
523: 'accepted_by' => $input['loginUserId'],
524: ]);
525: }
526: $appointmentNotification =
527: Transaction::with('acceptedPaymentUser')->whereAppointmentId($appointment['appointme
nt_unique_id'])->first();
528: $fullTime = $appointment->from_time.''.$appointment->from_time_type.' -
529: '.$appointment->to_time.''.$appointment->to_time_type.' '.'
530: '.Carbon::parse($appointment->date)->format('jS M, Y');
531: $patient = Patient::whereId($appointment->patient_id)->with('user')->first();
532: Notification::create([
533: 'title' => $appointmentNotification->acceptedPaymentUser->full_name.' changed the
payment
534: status '.Appointment::PAYMENT_TYPE[Appointment::PENDING].' to
535: '.Appointment::PAYMENT_TYPE[$appointment->payment_type].' for appointment
'.$fullTime,
536: 'type' => Notification::PAYMENT_DONE,
537: 'user_id' => $patient->user_id,
538: ]);
539: return $this->sendSuccess(__('messages.flash.payment_status_updated'));
540: }
541: public function cancelAppointment($patient_id, $appointment_unique_id):
RedirectResponse
542: {
543: //not complate query
544: $uniqueId = Crypt::decryptString($appointment_unique_id);
545: $appointment =
546: Appointment::whereAppointmentUniqueId($uniqueId)->wherePatientId($patient_id)->first
();
547: $appointment->update(['status' => Appointment::CANCELLED]);
548: return redirect(route('medical'));
549: }
550: public function doctorBookAppointment(Doctor $doctor): RedirectResponse
551: {
552: $data = [];
553: $data['doctor_id'] = $doctor['id'];
554: return redirect()->route('medicalAppointment')->with(['data' => $data]);
555: }
556: public function serviceBookAppointment(Service $service): RedirectResponse
557: {
558: $data = [];
559: $data['service'] = Service::whereStatus(Service::ACTIVE)->get()->pluck('name',
'id');
560: $data['service_id'] = $service['id'];
561: return redirect()->route('medicalAppointment')->with(['data' => $data]);
562: }
563: /**
564: * @return bool|JsonResponse
565: */
566: public function createGoogleEventForDoctor(Request $request)
567: {
568: if ($request->isXmlHttpRequest()) {
569: return $this->sendSuccess(__('messages.flash.operation_performed_success'));
570: }
571: return true;
572: }
573: /**
574: * @return bool|JsonResponse
575: */
576: public function createGoogleEventForPatient(Request $request)
577: {
578: if ($request->isXmlHttpRequest()) {
579: return $this->sendSuccess(__('messages.flash.operation_performed_success'));
580: }
581: return true;
582: }
583: public function manuallyPayment(Request $request): RedirectResponse
584: {
585: $input = $request->all();
586: $appointment = Appointment::findOrFail($input['appointmentId'])->load('patient');
587: $transaction = [
588: 'user_id' => $appointment->patient->user_id,
589: 'transaction_id' => Str::random(10),
590: 'appointment_id' => $appointment->appointment_unique_id,
591: 'amount' => $appointment->payable_amount,
592: 'type' => Appointment::MANUALLY,
593: 'status' => Transaction::PENDING,
594: ];
595: Transaction::create($transaction);
596: if (parse_url(url()->previous(), PHP_URL_PATH) == '/medical-appointment') {
597: return redirect(route('medicalAppointment'));
598: }
599: if (! getLogInUser()) {
600: return redirect(route('medical'));
601: }
602: if (getLogInUser()->hasRole('patient')) {
603: return redirect(route('patients.patient-appointments-index'));
604: }
605: if (getLogInUser()->hasRole('doctor')) {
606: return redirect(route('doctors.appointments'));
607: }
608: return redirect(route('appointments.index'));
609: }
610: public function appointmentPdf($id)
611: {
612: // $datas = Appointment::with(['patient.user', 'doctor.user',
613: 'services'])->findOrFail($id);
614: $datas = Appointment::with(['patient.user', 'doctor.user',
'services'])->findOrFail($id);
615: $pdf = Pdf::loadView('appointment_pdf.invoice', ['datas' => $datas]);
616: return $pdf->download('invoice.pdf');
617: }
618: }
[Http > Controllers > AuthorizePaymentController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Models\Appointment;
4: use App\Models\Doctor;
5: use App\Models\Notification;
6: use App\Models\Patient;
7: use App\Models\Transaction;
8: use Flash;
9: use Illuminate\Contracts\Foundation\Application;
10: use Illuminate\Http\RedirectResponse;
11: use Illuminate\Http\Request;
12: use Illuminate\Routing\Redirector;
13: use Illuminate\View\View;
14: use net\authorize\api\contract\v1 as AnetAPI;
15: use net\authorize\api\controller as AnetController;
16: use PayPalHttp\HttpException;
17: /**
18: * Class AuthorizePaymentController
19: */
20: class AuthorizePaymentController extends AppBaseController
21: {
22: public function onboard(Request $request): View
23: {
24: $appointmentId = $request->appointmentId;
25: $appointment = Appointment::whereId($appointmentId)->first();
26: $doctorName = Doctor::with('user')->whereId($appointment->doctor_id)->first();
27: $months = getMonth();
28: return view('payments.authorize.index', compact('appointment', 'doctorName',
'months'));
29: }
30: public function pay(Request $request)
31: {
32: $input = $request->input();
33: $appointmentId = $input['appointmentId'];
34: $appointment = Appointment::whereId($appointmentId)->first();
35: /* Create a merchantAuthenticationType object with authentication details
36: retrieved from the constants file */
37: $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
38: $merchantAuthentication->setName(config('payments.authorize.login_id'));
39: $merchantAuthentication->setTransactionKey(config('payments.authorize.transaction_key
'));
40: // Set the transaction's refId
41: $refId = 'ref'.time();
42: $cardNumber = preg_replace('/\s+/', '', $input['cardNumber']);
43: // Create the payment data for a credit card
44: $creditCard = new AnetAPI\CreditCardType();
45: $creditCard->setCardNumber($cardNumber);
46: $creditCard->setExpirationDate($input['expiration-year'].'-'.$input['expiration-month
']);
47: $creditCard->setCardCode($input['cvv']);
48: // Add the payment data to a paymentType object
49: $paymentOne = new AnetAPI\PaymentType();
50: $paymentOne->setCreditCard($creditCard);
51: // Create a TransactionRequestType object and add the previous objects to it
52: $transactionRequestType = new AnetAPI\TransactionRequestType();
53: $transactionRequestType->setTransactionType('authCaptureTransaction');
54: $transactionRequestType->setAmount($appointment->payable_amount);
55: $transactionRequestType->setPayment($paymentOne);
56: // Assemble the complete transaction request
57: $requests = new AnetAPI\CreateTransactionRequest();
58: $requests->setMerchantAuthentication($merchantAuthentication);
59: $requests->setRefId($refId);
60: $requests->setTransactionRequest($transactionRequestType);
61: // Create the controller and get the response
62: $controller = new AnetController\CreateTransactionController($requests);
63: $response =
64: $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SAN
DBOX);
65: if ($response != null) {
66: // Check to see if the API request was successfully received and acted upon
67: if ($response->getMessages()->getResultCode() == 'Ok') {
68: // Since the API request was successful, look for a transaction response
69: // and parse it to display the results of authorizing the card
70: $tresponse = $response->getTransactionResponse();
71: if ($tresponse != null && $tresponse->getMessages() != null) {
72: $message_text = $tresponse->getMessages()[0]->getDescription().', Transaction ID:
73: '.$tresponse->getTransId();
74: $msg_type = 'success_msg';
75: try {
76: $patient = Patient::with('user')->whereId($appointment->patient_id)->first();
77: $transaction = [
78: 'user_id' => $patient->user->id,
79: 'transaction_id' => $tresponse->getTransId(),
80: 'appointment_id' => $appointment['appointment_unique_id'],
81: 'amount' => intval($appointment['payable_amount']),
82: 'type' => Appointment::AUTHORIZE,
83: 'meta' => json_encode($tresponse),
84: ];
85: Transaction::create($transaction);
86: $appointment->update([
87: 'payment_method' => Appointment::AUTHORIZE,
88: 'payment_type' => Appointment::PAID,
89: ]);
90: Flash::success(__('messages.flash.appointment_created_payment_complete'));
91: Notification::create([
92: 'title' => Notification::APPOINTMENT_PAYMENT_DONE_PATIENT_MSG,
93: 'type' => Notification::PAYMENT_DONE,
94: 'user_id' => $patient->user->id,
95: ]);
96: if (! getLogInUser()) {
97: return redirect(route('medicalAppointment'));
98: }
99: if (getLogInUser()->hasRole('patient')) {
100: return redirect(route('patients.patient-appointments-index'));
101: }
102: return redirect(route('appointments.index'));
103: } catch (HttpException $ex) {
104: echo $ex->statusCode;
105: print_r($ex->getMessage());
106: }
107: } else {
108: $message_text = __('messages.flash.there_were');
109: $msg_type = 'error_msg';
110: if ($tresponse->getErrors() != null) {
111: $message_text = $tresponse->getErrors()[0]->getErrorText();
112: $msg_type = 'error_msg';
113: }
114: }
115: // Or, print errors if the API request wasn't successful
116: } else {
117: $message_text = __('messages.flash.there_were');
118: $msg_type = 'error_msg';
119: $tresponse = $response->getTransactionResponse();
120: if ($tresponse != null && $tresponse->getErrors() != null) {
121: $message_text = $tresponse->getErrors()[0]->getErrorText();
122: $msg_type = 'error_msg';
123: } else {
124: $message_text = $response->getMessages()->getMessage()[0]->getText();
125: $msg_type = 'error_msg';
126: }
127: }
128: } else {
129: $message_text = __('messages.no_response');
130: $msg_type = 'error_msg';
131: }
132: return back()->with($msg_type, $message_text);
133: }
134: /**
135: * @return Application|RedirectResponse|Redirector
136: */
137: public function failed(): RedirectResponse
138: {
139: Flash::error(__('messages.flash.appointment_created_payment_not_complete'));
140: if (! getLogInUser()) {
141: return redirect(route('medicalAppointment'));
142: }
143: if (getLogInUser()->hasRole('patient')) {
144: return redirect(route('patients.patient-appointments-index'));
145: }
146: return redirect(route('appointments.index'));
147: }
148: }
[Http > Controllers > BrandController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\CreateBrandRequest;
4: use App\Http\Requests\UpdateBrandRequest;
5: use App\Models\Brand;
6: use App\Models\Medicine;
7: use App\Repositories\BrandRepository;
8: use Exception;
9: use Flash;
10: use Illuminate\Contracts\Foundation\Application;
11: use Illuminate\Contracts\View\Factory;
12: use Illuminate\Http\JsonResponse;
13: use Illuminate\Http\RedirectResponse;
14: use Illuminate\Http\Request;
15: use Illuminate\Routing\Redirector;
16: use Illuminate\View\View;
17: class BrandController extends AppBaseController
18: {
19: /** @var BrandRepository */
20: private $brandRepository;
21: public function __construct(BrandRepository $brandRepo)
22: {
23: $this->brandRepository = $brandRepo;
24: }
25: /**
26: * Display a listing of the Brand.
27: *
28: * @param Request $request
29: * @return Factory|View
30: *
31: * @throws Exception
32: */
33: public function index(): View
34: {
35: return view('brands.index');
36: }
37: /**
38: * @return Application|Factory|View
39: */
40: public function create(): View
41: {
42: return view('brands.create');
43: }
44: /**
45: * Store a newly created Brand in storage.
46: *
47: * @return Application|RedirectResponse|Redirector
48: */
49: public function store(CreateBrandRequest $request): RedirectResponse
50: {
51: $input = $request->all();
52: $input['phone'] = preparePhoneNumber($input, 'phone');
53: $this->brandRepository->create($input);
54: Flash::success(__('messages.medicine_brands').'
55: '.__('messages.medicine.saved_successfully'));
56: return redirect(route('brands.index'));
57: }
58: /**
59: * @return Factory|View
60: */
61: public function show(Brand $brand): View
62: {
63: $medicines = $brand->medicines;
64: return view('brands.show', compact('medicines', 'brand'));
65: }
66: /**
67: * Show the form for editing the specified Brand.
68: *
69: * @return Application|Factory|View
70: */
71: public function edit(Brand $brand): View
72: {
73: return view('brands.edit', compact('brand'));
74: }
75: /**
76: * Update the specified Brand in storage.
77: *
78: * @return Application|RedirectResponse|Redirector
79: */
80: public function update(Brand $brand, UpdateBrandRequest $request): RedirectResponse
81: {
82: $input = $request->all();
83: $input['phone'] = preparePhoneNumber($input, 'phone');
84: $this->brandRepository->update($input, $brand->id);
85: Flash::success(__('messages.medicine_brands').'
86: '.__('messages.medicine.updated_successfully'));
87: return redirect(route('brands.index'));
88: }
89: /**
90: * Remove the specified Brand from storage.
91: *
92: *
93: * @throws Exception
94: */
95: public function destroy(Brand $brand): JsonResponse
96: {
97: $medicineBrandModel = [
98: Medicine::class,
99: ];
100: $result = canDelete($medicineBrandModel, 'brand_id', $brand->id);
101: if ($result) {
102: return $this->sendError(__('messages.medicine_brands').'
103: '.__('messages.medicine.cant_be_deleted'));
104: }
105: $brand->delete($brand->id);
106: return $this->sendSuccess(__('messages.medicine_brands').'
107: '.__('messages.medicine.deleted_successfully'));
108: }
109: }
[Http > Controllers > CategoryController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\CreateCategoryRequest;
4: use App\Http\Requests\UpdateCategoryRequest;
5: use App\Models\Category;
6: use App\Models\Medicine;
7: use App\Repositories\CategoryRepository;
8: use Exception;
9: use Illuminate\Contracts\View\Factory;
10: use Illuminate\Http\JsonResponse;
11: use Illuminate\Http\Request;
12: use Illuminate\View\View;
13: class CategoryController extends AppBaseController
14: {
15: /** @var CategoryRepository */
16: private $categoryRepository;
17: public function __construct(CategoryRepository $categoryRepo)
18: {
19: $this->categoryRepository = $categoryRepo;
20: }
21: /**
22: * Display a listing of the Category.
23: *
24: * @param Request $request
25: * @return Factory|View
26: *
27: * @throws Exception
28: */
29: public function index(): View
30: {
31: $data['statusArr'] = Category::STATUS_ARR;
32: return view('categories.index', $data);
33: }
34: /**
35: * Store a newly created Category in storage.
36: */
37: public function store(CreateCategoryRequest $request): JsonResponse
38: {
39: $input = $request->all();
40: $input['is_active'] = ! isset($input['is_active']) ? false : true;
41: $this->categoryRepository->create($input);
42: return $this->sendSuccess(__('messages.medicine.medicine_category').'
43: '.__('messages.medicine.saved_successfully'));
44: }
45: /**
46: * @return Factory|View
47: */
48: public function show(Category $category): View
49: {
50: $medicines = $category->medicines;
51: return view('categories.show', compact('medicines', 'category'));
52: }
53: /**
54: * Show the form for editing the specified Category.
55: */
56: public function edit(Category $category): JsonResponse
57: {
58: return $this->sendResponse($category,
59: __('messages.medicine.category_retrieved_successfully'));
60: }
61: /**
62: * Update the specified Category in storage.
63: */
64: public function update(Category $category, UpdateCategoryRequest $request):
JsonResponse
65: {
66: $input = $request->all();
67: $input['is_active'] = ! isset($input['is_active']) ? false : true;
68: $this->categoryRepository->update($input, $category->id);
69: return $this->sendSuccess(__('messages.medicine.medicine_category').'
70: '.__('messages.medicine.updated_successfully'));
71: }
72: /**
73: * Remove the specified Category from storage.
74: *
75: *
76: * @throws Exception
77: */
78: public function destroy(Category $category): JsonResponse
79: {
80: $medicineCategoryModel = [
81: Medicine::class,
82: ];
83: $result = canDelete($medicineCategoryModel, 'category_id', $category->id);
84: if ($result) {
85: return $this->sendError(__('messages.medicine.medicine_category').'
86: '.__('messages.medicine.cant_be_deleted'));
87: }
88: $this->categoryRepository->delete($category->id);
89: return $this->sendSuccess(__('messages.medicine.medicine_category').'
90: '.__('messages.medicine.deleted_successfully'));
91: }
92: public function activeDeActiveCategory(int $id): JsonResponse
93: {
94: $category = Category::findOrFail($id);
95: $category->is_active = ! $category->is_active;
96: $category->save();
97: return $this->sendSuccess(__('messages.medicine.status_updated_successfully'));
98: }
99: }
[Http > Controllers > CityController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\CreateCityRequest;
4: use App\Http\Requests\UpdateCityRequest;
5: use App\Models\Address;
6: use App\Models\City;
7: use App\Models\State;
8: use App\Repositories\CityRepository;
9: use Illuminate\Contracts\Foundation\Application;
10: use Illuminate\Contracts\View\Factory;
11: use Illuminate\Contracts\View\View;
12: use Illuminate\Http\JsonResponse;
13: class CityController extends AppBaseController
14: {
15: /** @var CityRepository */
16: private $cityRepository;
17: public function __construct(CityRepository $cityRepo)
18: {
19: $this->cityRepository = $cityRepo;
20: }
21: /**
22: * Display a listing of the City.
23: *
24: * @return Application|Factory|View
25: */
26: public function index(): \Illuminate\View\View
27: {
28: $states = State::orderBy('name', 'ASC')->pluck('name', 'id');
29: return view('cities.index', compact('states'));
30: }
31: /**
32: * Store a newly created City in storage.
33: */
34: public function store(CreateCityRequest $request): JsonResponse
35: {
36: $input = $request->all();
37: $city = $this->cityRepository->create($input);
38: return $this->sendSuccess(__('messages.flash.city_create'));
39: }
40: /**
41: * Show the form for editing the specified City.
42: */
43: public function edit(City $city): JsonResponse
44: {
45: return $this->sendResponse($city, __('messages.flash.city_retrieved'));
46: }
47: /**
48: * Update the specified City in storage.
49: */
50: public function update(UpdateCityRequest $request, City $city): JsonResponse
51: {
52: $input = $request->all();
53: $this->cityRepository->update($input, $city->id);
54: return $this->sendSuccess(__('messages.flash.city_update'));
55: }
56: public function destroy(City $city): JsonResponse
57: {
58: $checkRecord = Address::whereCityId($city->id)->exists();
59: if ($checkRecord) {
60: return $this->sendError(__('messages.flash.city_used'));
61: }
62: $city->delete();
63: return $this->sendSuccess(__('messages.flash.city_delete'));
64: }
65: }
[Http > Controllers > ClinicScheduleController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Models\ClinicSchedule;
4: use DB;
5: use Illuminate\Contracts\Foundation\Application;
6: use Illuminate\Contracts\View\Factory;
7: use Illuminate\Contracts\View\View;
8: use Illuminate\Http\JsonResponse;
9: use Illuminate\Http\Request;
10: class ClinicScheduleController extends AppBaseController
11: {
12: /**
13: * @return Application|Factory|View
14: */
15: public function index(): \Illuminate\View\View
16: {
17: $clinicSchedules = ClinicSchedule::all();
18: return view('clinic_schedule.index', compact('clinicSchedules'));
19: }
20: /**
21: * Store a newly created ClinicSchedule in storage.
22: */
23: public function store(Request $request): JsonResponse
24: {
25: $input = $request->all();
26: if (isset($input['checked_week_days'])) {
27: $oldWeekDays = ClinicSchedule::pluck('day_of_week')->toArray();
28: foreach (array_diff($oldWeekDays, $input['checked_week_days']) as $dayOfWeek) {
29: ClinicSchedule::whereDayOfWeek($dayOfWeek)->delete();
30: DB::table('session_week_days')->where('day_of_week', $dayOfWeek)->delete();
31: }
32: foreach ($input['checked_week_days'] as $day) {
33: $startTime = $input['clinicStartTimes'][$day];
34: $endTime = $input['clinicEndTimes'][$day];
35: if (strtotime($startTime) > strtotime($endTime)) {
36: return
$this->sendError(ClinicSchedule::WEEKDAY[$day].__('messages.start_time_invalid'));
37: }
38: ClinicSchedule::updateOrCreate(['day_of_week' => $day],
39: ['start_time' => $startTime, 'end_time' => $endTime]);
40: }
41: return $this->sendSuccess(__('messages.flash.clinic_save'));
42: }
43: ClinicSchedule::query()->delete();
44: DB::table('session_week_days')->delete();
45: return $this->sendSuccess(__('messages.flash.clinic_save'));
46: }
47: /**
48: * Store a newly created ClinicSchedule in storage.
49: */
50: public function checkRecord(Request $request): JsonResponse
51: {
52: $input = $request->all();
53: $message = __('messages.flash.some_doctors');
54: if (isset($input['checked_week_days'])) {
55: $unCheckedDay = array_diff(array_keys(ClinicSchedule::WEEKDAY),
56: $input['checked_week_days']);
57: $checkDayOfWeek = DB::table('session_week_days')->whereIn('day_of_week',
58: $unCheckedDay)->exists();
59: if ($checkDayOfWeek) {
60: return $this->sendError($message);
61: } else {
62: return $this->sendSuccess('');
63: }
64: }
65: $checkDayOfWeek = DB::table('session_week_days')->exists();
66: if ($checkDayOfWeek) {
67: return $this->sendError($message);
68: }
69: return $this->sendResponse('checkDayOfWeek', __('messages.flash.data_retrieve'));
70: }
71: /**
72: * Remove the specified ClinicSchedule from storage.
73: */
74: public function destroy(ClinicSchedule $clinicSchedule): JsonResponse
75: {
76: $clinicSchedule->delete();
77: return $this->sendSuccess(__('messages.flash.clinic_delete'));
78: }
79: }
[Http > Controllers > Controller.php]
1: <?php
2: namespace App\Http\Controllers;
3: use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
4: use Illuminate\Foundation\Validation\ValidatesRequests;
5: use Illuminate\Routing\Controller as BaseController;
6: class Controller extends BaseController
7: {
8: use AuthorizesRequests, ValidatesRequests;
9: }
[Http > Controllers > CountryController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\CreateCountryRequest;
4: use App\Http\Requests\UpdateCountryRequest;
5: use App\Models\Address;
6: use App\Models\Country;
7: use App\Repositories\CountryRepository;
8: use Illuminate\Contracts\Foundation\Application;
9: use Illuminate\Contracts\View\Factory;
10: use Illuminate\Contracts\View\View;
11: use Illuminate\Http\JsonResponse;
12: class CountryController extends AppBaseController
13: {
14: /** @var CountryRepository */
15: private $countryRepository;
16: public function __construct(CountryRepository $countryRepo)
17: {
18: $this->countryRepository = $countryRepo;
19: }
20: /**
21: * Display a listing of the Country.
22: *
23: * @return Application|Factory|View
24: */
25: public function index(): \Illuminate\View\View
26: {
27: return view('countries.index');
28: }
29: /**
30: * Store a newly created Country in storage.
31: */
32: public function store(CreateCountryRequest $request): JsonResponse
33: {
34: $input = $request->all();
35: $country = $this->countryRepository->create($input);
36: return $this->sendSuccess(__('messages.flash.country_create'));
37: }
38: /**
39: * Show the form for editing the specified Country.
40: */
41: public function edit(Country $country): JsonResponse
42: {
43: return $this->sendResponse($country, __('messages.flash.Country_retrieved'));
44: }
45: /**
46: * Update the specified Country in storage.
47: */
48: public function update(UpdateCountryRequest $request, Country $country): JsonResponse
49: {
50: $input = $request->all();
51: $input['short_code'] = strtoupper($input['short_code']);
52: $this->countryRepository->update($input, $country->id);
53: return $this->sendSuccess(__('messages.flash.country_update'));
54: }
55: public function destroy(Country $country): JsonResponse
56: {
57: $checkRecord = Address::whereCountryId($country->id)->exists();
58: if ($checkRecord) {
59: return $this->sendError(__('messages.flash.country_used'));
60: }
61: $country->delete();
62: return $this->sendSuccess(__('messages.flash.country_delete'));
63: }
64: }
[Http > Controllers > CurrencyController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\CreateCurrencyRequest;
4: use App\Http\Requests\UpdateCurrencyRequest;
5: use App\Models\Currency;
6: use App\Models\Setting;
7: use App\Repositories\CurrencyRepository;
8: use Illuminate\Contracts\Foundation\Application;
9: use Illuminate\Contracts\View\Factory;
10: use Illuminate\Contracts\View\View;
11: use Illuminate\Http\JsonResponse;
12: use Illuminate\Support\Facades\Cache;
13: class CurrencyController extends AppBaseController
14: {
15: /** @var CurrencyRepository */
16: private $currencyRepository;
17: public function __construct(CurrencyRepository $currencyRepo)
18: {
19: $this->currencyRepository = $currencyRepo;
20: }
21: /**
22: * Display a listing of the Currency.
23: *
24: * @return Application|Factory|View
25: */
26: public function index(): \Illuminate\View\View
27: {
28: return view('currencies.index');
29: }
30: /**
31: * Store a newly created Currency in storage.
32: */
33: public function store(CreateCurrencyRequest $request): JsonResponse
34: {
35: $input = $request->all();
36: $this->currencyRepository->store($input);
37: Cache::flush('currency');
38: return $this->sendSuccess(__('messages.flash.currency_create'));
39: }
40: public function edit(Currency $currency): JsonResponse
41: {
42: return $this->sendResponse($currency, __('messages.flash.currency_retrieved'));
43: }
44: /**
45: * Update the specified Currency in storage.
46: */
47: public function update(UpdateCurrencyRequest $request, Currency $currency):
JsonResponse
48: {
49: $input = $request->all();
50: $this->currencyRepository->update($input, $currency->id);
51: Cache::flush('currency');
52: return $this->sendSuccess(__('messages.flash.currency_update'));
53: }
54: /**
55: * Remove the specified Currency from storage.
56: */
57: public function destroy(Currency $currency): JsonResponse
58: {
59: $checkRecord = Setting::where('key', 'currency')->first()->value;
60: if ($checkRecord == $currency->id) {
61: return $this->sendError(__('messages.flash.currency_used'));
62: }
63: $currency->delete();
64: return $this->sendSuccess(__('messages.flash.currency_delete'));
65: }
66: }
[Http > Controllers > DashboardController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Repositories\DashboardRepository;
4: use Illuminate\Contracts\Foundation\Application;
5: use Illuminate\Contracts\View\Factory;
6: use Illuminate\Contracts\View\View;
7: use Illuminate\Http\JsonResponse;
8: use Illuminate\Http\Request;
9: class DashboardController extends AppBaseController
10: {
11: /* @var DashboardRepository */
12: private $dashboardRepository;
13: /**
14: * DashboardController constructor.
15: */
16: public function __construct(DashboardRepository $dashboardRepo)
17: {
18: $this->dashboardRepository = $dashboardRepo;
19: }
20: /**
21: * @return Application|Factory|View|JsonResponse
22: */
23: public function index(Request $request)
24: {
25: $data = $this->dashboardRepository->getData();
26: $appointmentChartData =
27: $this->dashboardRepository->getAppointmentChartData($request->all());
28: if ($request->ajax()) {
29: $appointmentFilterChartData =
30: $this->dashboardRepository->getAppointmentChartData($request->all());
31: return $this->sendResponse($appointmentFilterChartData,
__('messages.filter_success'));
32: }
33: return view('dashboard.index', compact('data', 'appointmentChartData'));
34: }
35: /**
36: * @param Request $request *
37: */
38: public function getPatientList(Request $request)
39: {
40: $input = $request->all();
41: $data['patients'] = $this->dashboardRepository->patientData($input);
42: return $this->sendResponse($data, __('messages.flash.patients_retrieve'));
43: }
44: /**
45: * @return Application|Factory|View
46: */
47: public function doctorDashboard(): \Illuminate\View\View
48: {
49: $appointments = $this->dashboardRepository->getDoctorData();
50: return view('doctor_dashboard.index', compact('appointments'));
51: }
52: public function getDoctorAppointment(Request $request): JsonResponse
53: {
54: $input = $request->all();
55: $data['patients'] = $this->dashboardRepository->doctorAppointment($input);
56: return $this->sendResponse($data, __('messages.flash.patients_retrieve'));
57: }
58: /**
59: * @return Application|Factory|View
60: */
61: public function patientDashboard(): \Illuminate\View\View
62: {
63: $data = $this->dashboardRepository->getPatientData();
64: return view('patient_dashboard.index', compact('data'));
65: }
66: }
[Http > Controllers > DoctorSessionController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\CreateDoctorSessionRequest;
4: use App\Http\Requests\UpdateDoctorSessionRequest;
5: use App\Models\Appointment;
6: use App\Models\ClinicSchedule;
7: use App\Models\DoctorHoliday;
8: use App\Models\DoctorSession;
9: use App\Models\WeekDay;
10: use App\Repositories\DoctorSessionRepository;
11: use Carbon\Carbon;
12: use DateTime;
13: use Exception;
14: use Illuminate\Contracts\Foundation\Application;
15: use Illuminate\Contracts\View\Factory;
16: use Illuminate\Contracts\View\View;
17: use Illuminate\Http\JsonResponse;
18: use Illuminate\Http\RedirectResponse;
19: use Illuminate\Http\Request;
20: use Illuminate\Routing\Redirector;
21: use Illuminate\Support\Facades\App;
22: use Illuminate\Support\Facades\DB;
23: use Laracasts\Flash\Flash;
24: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
25: class DoctorSessionController extends AppBaseController
26: {
27: /** @var DoctorSessionRepository */
28: private $doctorSessionRepository;
29: public function __construct(DoctorSessionRepository $doctorSessionRepo)
30: {
31: $this->doctorSessionRepository = $doctorSessionRepo;
32: }
33: /**
34: * Display a listing of the DoctorSession.
35: *
36: * @return Application|Factory|View
37: */
38: public function index(): \Illuminate\View\View
39: {
40: return view('doctor_sessions.index');
41: }
42: /**
43: * Show the form for creating a new DoctorSession.
44: *
45: * @return Application|Factory|View
46: */
47: public function create(): \Illuminate\View\View
48: {
49: $doctorsList = $this->doctorSessionRepository->getSyncList();
50: return view('doctor_sessions.create', compact('doctorsList'));
51: }
52: /**
53: * Store a newly created DoctorSession in storage.
54: */
55: public function store(CreateDoctorSessionRequest $request)
56: {
57: $input = $request->all();
58: $result = $this->doctorSessionRepository->store($input);
59: if (! $result['success']) {
60: return $this->sendError($result);
61: }
62: return $this->sendSuccess(__('messages.flash.schedule_crete'));
63: }
64: /**
65: * Display the specified DoctorSession.
66: *
67: * @return Application|Factory|View
68: */
69: public function show(DoctorSession $doctorSession)
70: {
71: if (empty($doctorSession)) {
72: Flash::error(__('messages.flash.doctor_session_not_found'));
73: return redirect(getDoctorSessionURL());
74: }
75: return view('doctor_sessions.show', compact('doctorSession'));
76: }
77: /**
78: * Show the form for editing the specified DoctorSession.
79: *
80: * @return Application|Factory|View
81: */
82: public function edit($id)
83: {
84: if (getLogInUser()->hasRole('doctor')) {
85: $doctorSession =
86: DoctorSession::with('doctor.user')->whereDoctorId(getLogInUser()->doctor->id)->first(
);
87: } else {
88: $doctorSession = DoctorSession::with('doctor.user')->findOrFail($id);
89: }
90: $doctorsList = $this->doctorSessionRepository->getSyncList();
91: if (empty($doctorSession)) {
92: Flash::error(__('messages.flash.schedule_not_found'));
93: return redirect(route('doctor-sessions.index'));
94: }
95: $sessionWeekDays = $doctorSession->sessionWeekDays;
96: return view('doctor_sessions.edit', compact('doctorSession', 'doctorsList',
97: 'sessionWeekDays'));
98: }
99: /**
100: * Update the specified DoctorSession in storage.
101: */
102: public function update(UpdateDoctorSessionRequest $request, DoctorSession
$doctorSession):
103: JsonResponse
104: {
105: if (empty($doctorSession)) {
106: return $this->sendError(__('messages.flash.doctor_session_not_found'));
107: }
108: $result = $this->doctorSessionRepository->updateDoctorSession($request->all(),
109: $doctorSession);
110: if (! $result['success']) {
111: return $this->sendError($result);
112: }
113: return $this->sendSuccess(__('messages.flash.schedule_update'));
114: }
115: /**
116: * Remove the specified DoctorSession from storage.
117: */
118: public function destroy(DoctorSession $doctorSession): JsonResponse
119: {
120: try {
121: DB::beginTransaction();
122: $doctorSession->delete();
123: $doctorSession->sessionWeekDays()->delete();
124: DB::commit();
125: return $this->sendSuccess(__('messages.flash.schedule_delete'));
126: } catch (Exception $e) {
127: throw new UnprocessableEntityHttpException($e->getMessage());
128: }
129: }
130: /**
131: * @throws Exception
132: */
133: public function getDoctorSession(Request $request): JsonResponse
134: {
135: $holidaydate = $request->get('date');
136: $doctorId = $request->get('adminAppointmentDoctorId');
137: $timezone_offset_minutes = $request->get('timezone_offset_minutes');
138: $doctor_holiday = DoctorHoliday::where('doctor_id', $doctorId)->where('date',
139: $holidaydate)->get();
140: if (! $doctor_holiday->count() == 0) {
141: return $this->sendError(__('messages.flash.doctor_not_available'));
142: }
143: // Convert minutes to seconds
144: $timezone_name = timezone_name_from_abbr('', $timezone_offset_minutes * 60, false);
145: $date = Carbon::createFromFormat('Y-m-d', $request->date);
146: $doctorWeekDaySessions =
147: WeekDay::whereDayOfWeek($date->dayOfWeek)->whereDoctorId($doctorId)->with('doctorSes
sion')->get();
148: if ($doctorWeekDaySessions->count() == 0) {
149: if (! empty(getLogInUser()->language)) {
150: App::setLocale(getLogInUser()->language);
151: } else {
152: App::setLocale($request->session()->get('languageName'));
153: }
154: return $this->sendError(__('messages.flash.no_available_slots'));
155: }
156: $appointments = Appointment::whereDoctorId($doctorId)->whereIn('status',
157: [Appointment::BOOKED, Appointment::CHECK_IN, Appointment::CHECK_OUT])->get();
158: $bookedSlot = [];
159: $bookingSlot = [];
160: foreach ($appointments as $appointment) {
161: if ($appointment->date == $request->date) {
162: $bookedSlot[] = $appointment->from_time.' '.$appointment->from_time_type.' -
163: '.$appointment->to_time.' '.$appointment->to_time_type;
164: }
165: }
166: foreach ($doctorWeekDaySessions as $index => $doctorWeekDaySession) {
167: date_default_timezone_set($timezone_name);
168: $doctorSession = $doctorWeekDaySession->doctorSession;
169: // convert 12 hours to 24 hours
170: $startTime = date('H:i', strtotime($doctorWeekDaySession->full_start_time));
171: $endTime = date('H:i', strtotime($doctorWeekDaySession->full_end_time));
172: $slots = $this->getTimeSlot($doctorSession->session_meeting_time, $startTime,
$endTime);
173: $gap = $doctorSession->session_gap;
174: $isSameWeekDay = (Carbon::now()->dayOfWeek == $date->dayOfWeek) &&
175: (Carbon::now()->isSameDay($date));
176: foreach ($slots as $key => $slot) {
177: $key--;
178: if ($key != 0) {
179: $slotStartTime = date('h:i A',
180: strtotime('+'.$gap * $key.' minutes', strtotime($slot[0])));
181: $slotEndTime = date('h:i A',
182: strtotime('+'.$gap * $key.' minutes', strtotime($slot[1])));
183: if (strtotime($doctorWeekDaySession->full_end_time) < strtotime($slotEndTime)) {
184: break;
185: }
186: if (strtotime($slotStartTime) < strtotime($slotEndTime)) {
187: if (($isSameWeekDay && strtotime($slotStartTime) > strtotime(date('h:i A'))) || !
188: $isSameWeekDay) {
189: $startTimeOrg = Carbon::parse(date('h:i A', strtotime($slotStartTime)));
190: $slotStartTimeCarbon = Carbon::parse(date('h:i A', strtotime($startTime)));
191: $slotEndTimeCarbon = Carbon::parse(date('h:i A', strtotime($endTime)));
192: if (! $startTimeOrg->between($slotStartTimeCarbon, $slotEndTimeCarbon)) {
193: break;
194: }
195: if (in_array(($slotStartTime.' - '.$slotEndTime), $bookingSlot)) {
196: break;
197: }
198: $bookingSlot[] = $slotStartTime.' - '.$slotEndTime;
199: }
200: }
201: } else {
202: if (($isSameWeekDay && strtotime($slot[0]) > strtotime(date('h:i A'))) || !
203: $isSameWeekDay) {
204: if (in_array((date('h:i A', strtotime($slot[0])).' - '.date('h:i A',
205: strtotime($slot[1]))),
206: $bookingSlot)) {
207: break;
208: }
209: $bookingSlot[] = date('h:i A', strtotime($slot[0])).' - '.date('h:i A',
210: strtotime($slot[1]));
211: }
212: }
213: }
214: }
215: $slots = [
216: 'bookedSlot' => ! empty($bookedSlot) ? $bookedSlot : null,
217: 'slots' => $bookingSlot,
218: ];
219: return $this->sendResponse($slots, __('messages.flash.retrieve'));
220: }
221: /**
222: * @throws Exception
223: */
224: public function getTimeSlot($interval, $start_time, $end_time)
225: {
226: $start = new DateTime($start_time);
227: $end = new DateTime($end_time);
228: $carbonStart = Carbon::createFromFormat('H:i', $start_time);
229: $carbonEnd = Carbon::createFromFormat('H:i', $end_time);
230: $startTime = $start->format('H:i');
231: $endTime = $originalEndTime = $end->format('H:i');
232: $i = 0;
233: $time = [];
234: while (strtotime($startTime) <= strtotime($endTime)) {
235: $start = $startTime;
236: $end = date('H:i', strtotime('+'.$interval.' minutes', strtotime($startTime)));
237: $startTime = date('H:i', strtotime('+'.$interval.' minutes',
strtotime($startTime)));
238: if (! Carbon::createFromFormat('H:i', $start)->isBetween($carbonStart,
239: $carbonEnd) || ! Carbon::createFromFormat('H:i', $end)->isBetween($carbonStart,
240: $carbonEnd)) {
241: break;
242: }
243: $i++;
244: if (strtotime($startTime) <= strtotime($endTime)) {
245: $time[$i][] = $start;
246: $time[$i][] = $end;
247: }
248: if (strtotime($startTime) >= strtotime($originalEndTime)) {
249: break;
250: }
251: if (strtotime($start) >= strtotime($end)) {
252: break;
253: }
254: }
255: return $time;
256: }
257: /**
258: * @return mixed
259: */
260: public function getSlotByGap(Request $request)
261: {
262: $gap = $request->get('gap');
263: $day = $request->get('day');
264: $clinicSchedule = ClinicSchedule::whereDayOfWeek($day)->first();
265: $slots = getSlotByGap($clinicSchedule->start_time, $clinicSchedule->end_time);
266: $html = view('doctor_sessions.slot', ['slots' => $slots, 'day' => $day])->render();
267: return $this->sendResponse($html, __('messages.flash.retrieve'));
268: }
269: /**
270: * @return Application|Factory|View|RedirectResponse|Redirector
271: */
272: public function doctorScheduleEdit()
273: {
274: $doctorSession = DoctorSession::whereDoctorId(getLogInUser()->doctor->id)->first();
275: if (empty($doctorSession)) {
276: Flash::error(__('messages.flash.schedule_not_found'));
277: return redirect(route('doctor-sessions.index'));
278: }
279: $doctorsList = $this->doctorSessionRepository->getSyncList();
280: $sessionWeekDays = $doctorSession->sessionWeekDays;
281: return view('doctor_sessions.edit', compact('doctorSession', 'doctorsList',
282: 'sessionWeekDays'));
283: }
284: }
[Http > Controllers > GeneratePatientSmartCardsController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use Illuminate\Http\Request;
4: use App\Models\Patient;
5: use App\Models\SmartPatientCards;
6: use App\Repositories\GeneratePatientSmartCardsRepository;
7: use SimpleSoftwareIO\QrCode\Facades\QrCode;
8: use App\Models\Setting;
9: use Flash;
10: use PDF;
11: class GeneratePatientSmartCardsController extends AppBaseController
12: {
13: private $GeneratePatientSmartCardsRepository;
14: public function __construct(GeneratePatientSmartCardsRepository $staffRepo)
15: {
16: $this->GeneratePatientSmartCardsRepository = $staffRepo;
17: }
18: public function index()
19: {
20: $template = SmartPatientCards::pluck('template_name', 'id');
21: $patient = Patient::where('template_id',
22: null)->with('user')->get()->pluck('user.first_name', 'user.id');
23: $logo = Setting::where('key', 'logo')->pluck('value');
24: return view('generate_patient_smart_cards.index', compact('template', 'patient',
'logo'));
25: }
26: public function store(Request $request)
27: {
28: $input = $request->all();
29: $this->GeneratePatientSmartCardsRepository->store($input);
30: Flash::success(__('messages.smart_patient_card.patient_smart_card_created'));
31: if (isRole('doctor')) {
32: return redirect(route('doctors.generate-patient-smart-cards.index'));
33: }
34: if (isRole('clinic_admin')) {
35: return redirect(route('generate-patient-smart-cards.index'));
36: }
37: }
38: public function destroy($id)
39: {
40: Patient::where('id', $id)->update(['template_id' => null, 'qr_code' => null]);
41: return
$this->sendSuccess(__('messages.smart_patient_card.patient_smart_card_deleted'));
42: }
43: public function cardDelail($id)
44: {
45: $data = Patient::with('smartPatientCard', 'user', 'address')->where('id',
$id)->first();
46: $img = $data->profile;
47: $clinic_name = Setting::where('key','clinic_name')->pluck('value')->first();
48: $address_one = Setting::where('key','address_one')->pluck('value')->first();
49: return response()->json(['data' => $data, 'img' => $img, 'clinic_name' =>
$clinic_name,
50: 'address_one' => $address_one,]);
51: }
52: public function smartCardPdf($id)
53: {
54: $datas = Patient::with('smartPatientCard', 'user', 'address')->findOrFail($id);
55: $logo = Setting::where('key', 'logo')->pluck('value')->first();
56: $clinic_name = Setting::where('key','clinic_name')->pluck('value')->first();
57: $address_one = Setting::where('key','address_one')->pluck('value')->first();
58: $pdf = PDF::loadView('smart_card_pdf.smart_card_pdf', ['datas' => $datas,'logo' =>
59: $logo,'clinic_name' => $clinic_name,'address_one' => $address_one]);
60: return $pdf->download('PatientSmartCard.pdf');
61: }
62: public function cardQr($id)
63: {
64: $qr = Patient::findOrFail($id);
65: $qrCode =
QrCode::size(90)->generate(route('patient_show').'/'.$qr->patient_unique_id);
66: return $qrCode;
67: }
68: }
[Http > Controllers > GoogleCalendarController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Models\AppointmentGoogleCalendar;
4: use App\Models\GoogleCalendarIntegration;
5: use App\Models\GoogleCalendarList;
6: use App\Repositories\GoogleCalendarRepository;
7: use Carbon\Carbon;
8: use Flash;
9: use Google_Client;
10: use Google_Service_Calendar;
11: use Google_Service_Calendar_EventDateTime;
12: use Illuminate\Http\RedirectResponse;
13: use Illuminate\Http\Request;
14: use Illuminate\Support\Facades\App;
15: use Illuminate\Support\Facades\Log;
16: use Illuminate\View\View;
17: use Laracasts\Flash\Flash as FlashFlash;
18: use Google\Service;
19: /**
20: * Class GoogleCalendarController
21: */
22: class GoogleCalendarController extends AppBaseController
23: {
24: public $client;
25: public function __construct()
26: {
27: $name = config('app.google_oauth_path');
28: if (empty($name)) {
29: return;
30: }
31: $this->client = new Google_Client();
32: // Set the application name, this is included in the User-Agent HTTP header.
33: $this->client->setApplicationName(config('app.name'));
34: // Set the authentication credentials we downloaded from Google.
35:
36: $this->client->setAuthConfig(resource_path('google-oath/'.config('app.google_oauth_pa
th')));
37: // Setting offline here means we can pull data from the venue's calendar when they
are not
38: actively using the site.
39: $this->client->setAccessType('offline');
40: // This will include any other scopes (Google APIs) previously granted by the venue
41: $this->client->setIncludeGrantedScopes(true);
42: // Set this to force to consent form to display.
43: $this->client->setApprovalPrompt('force');
44: // Add the Google Calendar scope to the request.
45: $this->client->addScope(Google_Service_Calendar::CALENDAR);
46: }
47: public function oauth(): RedirectResponse
48: {
49: if($this->client == null){
50: return redirect()->back();
51: }
52: $authUrl = $this->client->createAuthUrl();
53: $filteredUrl = filter_var($authUrl, FILTER_SANITIZE_URL);
54: return redirect($filteredUrl);
55: }
56: public function fetchCalendarListAndSyncToDB()
57: {
58: $gcHelper = new Google_Service_Calendar($this->client);
59: // Use the Google Client calendar service. This gives us methods for interacting
60: // with the Google Calendar API
61: $calendarList = $gcHelper->calendarList->listCalendarList();
62: $googleCalendarList = [];
63: foreach ($calendarList->getItems() as $calendarListEntry) {
64: if ($calendarListEntry->accessRole == 'owner') {
65: $googleCalendarList[] = GoogleCalendarList::create([
66: 'user_id' => getLogInUserId(),
67: 'calendar_name' => $calendarListEntry['summary'],
68: 'google_calendar_id' => $calendarListEntry['id'],
69: 'meta' => json_encode($calendarListEntry),
70: ]);
71: }
72: }
73: return $googleCalendarList;
74: }
75: public function redirect(Request $request): RedirectResponse
76: {
77: try {
78: $accessToken = $this->client->fetchAccessTokenWithAuthCode($request->get('code'));
79: $exists = GoogleCalendarIntegration::whereUserId(getLogInUserId())->exists();
80: if ($exists) {
81: GoogleCalendarIntegration::whereUserId(getLogInUserId())->delete();
82: GoogleCalendarList::whereUserId(getLogInUserId())->delete();
83: }
84: $googleCalendarIntegration = GoogleCalendarIntegration::create([
85: 'user_id' => getLogInUserId(),
86: 'access_token' => $accessToken['access_token'],
87: 'last_used_at' => Carbon::now(),
88: 'meta' => json_encode($accessToken),
89: ]);
90: $this->client->setAccessToken($accessToken);
91: $calendarLists = $this->fetchCalendarListAndSyncToDB();
92: } catch (\Exception $exception) {
93: Log::error($exception->getMessage());
94: }
95: // store token to DB here
96: // google_access_token
97: // - user_id
98: // - access_token
99: // meta (json)
100: // last_used_at
101: // we must need to generate new token within hr, as access token is valid for hr
102: Flash::success(__('messages.flash.google_calendar_connect'));
103: if (getLogInUser()->hasRole('doctor')) {
104: return redirect(route('doctors.googleCalendar.index'));
105: } elseif (getLogInUser()->hasRole('patient')) {
106: return redirect(route('patients.googleCalendar.index'));
107: }
108: }
109: public function show($eventId)
110: {
111: $accessToken = $this->getAccessToken();
112: if ($accessToken) {
113: $this->client->setAccessToken($accessToken);
114: $service = new Google_Service_Calendar($this->client);
115: $event = $service->events->get('primary', $eventId);
116: if (! $event) {
117: return response()->json(['status' => 'error', 'message' =>
118: __('messages.flash.something_went_wrong')]);
119: }
120: return response()->json(['status' => 'success', 'data' => $event]);
121: } else {
122: return redirect()->route('oauthCallback');
123: }
124: }
125: public function update(Request $request, $eventId)
126: {
127: $accessToken = $this->getAccessToken();
128: if ($accessToken) {
129: $this->client->setAccessToken($accessToken);
130: $service = new Google_Service_Calendar($this->client);
131: $startDateTime = Carbon::parse($request->start_date)->toRfc3339String();
132: $eventDuration = 30; //minutes
133: if ($request->has('end_date')) {
134: $endDateTime = Carbon::parse($request->end_date)->toRfc3339String();
135: } else {
136: $endDateTime =
137: Carbon::parse($request->start_date)->addMinutes($eventDuration)->toRfc3339String();
138: }
139: // retrieve the event from the API.
140: $event = $service->events->get('primary', $eventId);
141: $event->setSummary($request->title);
142: $event->setDescription($request->description);
143: //start time
144: $start = new Google_Service_Calendar_EventDateTime();
145: $start->setDateTime($startDateTime);
146: $event->setStart($start);
147: //end time
148: $end = new Google_Service_Calendar_EventDateTime();
149: $end->setDateTime($endDateTime);
150: $event->setEnd($end);
151: $updatedEvent = $service->events->update('primary', $event->getId(), $event);
152: if (! $updatedEvent) {
153: return response()->json(['status' => 'error', 'message' =>
154: __('messages.flash.something_went_wrong')]);
155: }
156: return response()->json(['status' => 'success', 'data' => $updatedEvent]);
157: } else {
158: return redirect()->route('oauthCallback');
159: }
160: }
161: public function destroy($eventId): RedirectResponse
162: {
163: $accessToken = $this->getAccessToken();
164: if ($accessToken) {
165: $this->client->setAccessToken($accessToken);
166: $service = new Google_Service_Calendar($this->client);
167: $service->events->delete('primary', $eventId);
168: } else {
169: return redirect()->route('oauthCallback');
170: }
171: }
172: public function googleCalendar(): View
173: {
174: $data['googleCalendarIntegrationExists'] =
175: GoogleCalendarIntegration::whereUserId(getLogInUserId())->exists();
176: $data['googleCalendarLists'] =
177: \App\Models\GoogleCalendarList::with('appointmentGoogleCalendar')
178: ->whereUserId(getLogInUserId())
179: ->get();
180: $data['checkTimeZone'] = getLogInUser();
181: return view('connect_google_calendar.index', compact('data'));
182: }
183: public function appointmentGoogleCalendarStore(Request $request)
184: {
185: $appointmentGoogleCalendars =
186: AppointmentGoogleCalendar::whereUserId(getLogInUserId())->get();
187: foreach ($appointmentGoogleCalendars as $appointmentGoogleCalendar) {
188: $appointmentGoogleCalendar->delete();
189: }
190: $input = $request->all();
191: $googleCalendarIds = $input['google_calendar'];
192: foreach ($googleCalendarIds as $googleCalendarId) {
193: $googleCalendarListId =
GoogleCalendarList::find($googleCalendarId)->google_calendar_id;
194: $data = [
195: 'user_id' => getLogInUserId(),
196: 'google_calendar_list_id' => $googleCalendarId,
197: 'google_calendar_id' => $googleCalendarListId,
198: ];
199: AppointmentGoogleCalendar::create($data);
200: }
201: return $this->sendSuccess(__('messages.flash.calender_added'));
202: }
203: public function disconnectGoogleCalendar(): RedirectResponse
204: {
205: AppointmentGoogleCalendar::whereUserId(getLogInUserId())->delete();
206: GoogleCalendarIntegration::whereUserId(getLogInUserId())->delete();
207: GoogleCalendarList::whereUserId(getLogInUserId())->delete();
208: Flash::success(__('messages.flash.google_calendar_disconnect'));
209: if (getLogInUser()->hasRole('doctor')) {
210: return redirect(route('doctors.googleCalendar.index'));
211: } elseif (getLogInUser()->hasRole('patient')) {
212: return redirect(route('patients.googleCalendar.index'));
213: }
214: }
215: public function syncGoogleCalendarList()
216: {
217: /** @var GoogleCalendarRepository $repo */
218: $repo = App::make(GoogleCalendarRepository::class);
219: $repo->syncCalendarList(getLogInUser());
220: return $this->sendSuccess(__('messages.flash.google_calendar_update'));
221: }
222: }
[Http > Controllers > HolidayContoller.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\CreateHolidayRequest;
4: use App\Models\Doctor;
5: use App\Models\DoctorHoliday;
6: use App\Models\User;
7: use App\Repositories\HolidayRepository;
8: use Flash;
9: use Illuminate\Http\RedirectResponse;
10: use Illuminate\Http\Request;
11: use Illuminate\View\View;
12: class HolidayContoller extends AppBaseController
13: {
14: /** @var HolidayRepository */
15: private $holidayRepository;
16: public function __construct(HolidayRepository $holidayRepo)
17: {
18: $this->holidayRepository = $holidayRepo;
19: }
20: /**
21: * Display a listing of the resource.
22: */
23: public function index(): View
24: {
25: return view('doctor_holiday.index');
26: }
27: /**
28: * Show the form for creating a new resource.
29: */
30: public function create(): View
31: {
32: $doctor = Doctor::with('user')->get()->where('user.status',
33: User::ACTIVE)->pluck('user.full_name',
34: 'id');
35: return view('doctor_holiday.create', compact('doctor'));
36: }
37: /**
38: * @return
39: \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illum
inate\Routing\Redirector.
40: */
41: public function store(CreateHolidayRequest $request): RedirectResponse
42: {
43: $input = $request->all();
44: $holiday = $this->holidayRepository->store($input);
45: if ($holiday) {
46: Flash::success(__('messages.flash.doctor_holiday'));
47: return redirect(route('holidays.index'));
48: } else {
49: Flash::error(__('messages.flash.holiday_already_is_exist'));
50: return redirect(route('holidays.create'));
51: }
52: }
53: /**
54: * Display the specified resource.
55: *
56: * @return \Illuminate\Http\Response
57: */
58: public function show(int $id)
59: {
60: //
61: }
62: /**
63: * Show the form for editing the specified resource.
64: *
65: * @return \Illuminate\Http\Response
66: */
67: public function edit(int $id)
68: {
69: //
70: }
71: /**
72: * Update the specified resource in storage.
73: *
74: * @return \Illuminate\Http\Response
75: */
76: public function update(Request $request, int $id)
77: {
78: //
79: }
80: /**
81: * Remove the specified resource from storage.
82: *
83: * @return \Illuminate\Http\Response
84: */
85: public function destroy(int $id)
86: {
87: $checkRecord = DoctorHoliday::destroy($id);
88: return $this->sendSuccess(__('messages.flash.city_delete'));
89: }
90: /**
91: * @return
92: \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illu
minate\Contracts\View\View
93: */
94: public function holiday(): View
95: {
96: return view('holiday.index');
97: }
98: public function doctorCreate(): View
99: {
100: $doctor = Doctor::whereUserId(getLogInUserId())->first('id');
101: $doctorId = $doctor['id'];
102: return view('holiday.create', compact('doctorId'));
103: }
104: /**
105: * @return
106: \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illu
minate\Routing\Redirector.
107: */
108: public function doctorStore(CreateHolidayRequest $request): RedirectResponse
109: {
110: $input = $request->all();
111: $holiday = $this->holidayRepository->store($input);
112: if ($holiday) {
113: Flash::success(__('messages.flash.doctor_holiday'));
114: return redirect(route('doctors.holiday'));
115: } else {
116: Flash::error(__('messages.flash.holiday_already_is_exist'));
117: return redirect(route('doctors.holiday-create'));
118: }
119: }
120: public function doctorDestroy($id): mixed
121: {
122: $doctorHoliday = DoctorHoliday::whereId($id)->firstOrFail();
123: if ($doctorHoliday->doctor_id !== getLogInUser()->doctor->id) {
124: return $this->sendError(__('messages.common.not_allow__assess_record'));
125: }
126: $doctorHoliday->destroy($id);
127: return $this->sendSuccess(__('messages.flash.city_delete'));
128: }
129: }
[Http > Controllers > LiveConsultationController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App;
4: use App\Http\Requests\CreateZoomCredentialRequest;
5: use App\Http\Requests\LiveConsultationRequest;
6: use App\Models\Doctor;
7: use App\Models\LiveConsultation;
8: use App\Models\Patient;
9: use App\Models\User;
10: use App\Models\UserZoomCredential;
11: use App\Repositories\LiveConsultationRepository;
12: use App\Repositories\ZoomRepository;
13: use Exception;
14: use Illuminate\Contracts\Foundation\Application;
15: use Illuminate\Contracts\View\Factory;
16: use Illuminate\Contracts\View\View;
17: use Illuminate\Http\JsonResponse;
18: use Illuminate\Http\RedirectResponse;
19: use Illuminate\Http\Request;
20: use Illuminate\Support\Facades\App as FacadesApp;
21: use Laracasts\Flash\Flash;
22: class LiveConsultationController extends AppBaseController
23: {
24: /** @var LiveConsultationRepository */
25: /** @var ZoomRepository */
26: private $liveConsultationRepository;
27: private $zoomRepository;
28: /**
29: * LiveConsultationController constructor.
30: */
31: public function __construct(
32: LiveConsultationRepository $liveConsultationRepository,
33: ZoomRepository $zoomRepository
34: ) {
35: $this->liveConsultationRepository = $liveConsultationRepository;
36: $this->zoomRepository = $zoomRepository;
37: }
38: /**
39: * @return Application|Factory|View
40: *
41: * @throws Exception
42: */
43: public function index(): \Illuminate\View\View
44: {
45: $doctors = Doctor::with('user')->get()->where('user.status', '=',
User::ACTIVE)->pluck(
46: 'user.full_name',
47: 'id'
48: )->sort();
49: $patients = Patient::with('user')->get()->where('user.status', '=',
User::ACTIVE)->pluck(
50: 'user.full_name',
51: 'id'
52: )->sort();
53: $type = LiveConsultation::STATUS_TYPE;
54: $status = LiveConsultation::status;
55: return view('live_consultations.index', compact('doctors', 'patients', 'type',
'status'));
56: }
57: public function store(LiveConsultationRequest $request): JsonResponse
58: {
59: try {
60: $this->liveConsultationRepository->store($request->all());
61: $this->liveConsultationRepository->createNotification($request->all());
62: return $this->sendSuccess(__('messages.flash.live_consultation_save'));
63: } catch (Exception $e) {
64: return $this->sendError($e->getMessage());
65: }
66: }
67: public function show(LiveConsultation $liveConsultation):
68: Factory|View|JsonResponse|Application
69: {
70: if (getLogInUser()->hasrole('patient')) {
71: if ($liveConsultation->patient_id !== getLogInUser()->patient->id) {
72: return $this->sendError(__('messages.common.not_allow__assess_record'));
73: }
74: }
75: if (getLogInUser()->hasrole('doctor')) {
76: if ($liveConsultation->doctor_id !== getLogInUser()->doctor->id) {
77: return $this->sendError(__('messages.common.not_allow__assess_record'));
78: }
79: }
80: $data['liveConsultation'] = LiveConsultation::with([
81: 'user', 'patient.user', 'doctor.user',
82: ])->find($liveConsultation->id);
83: return $this->sendResponse($data, __('messages.flash.live_consultation_retrieved'));
84: }
85: public function edit(LiveConsultation $liveConsultation): JsonResponse
86: {
87: if (getLogInUser()->hasrole('doctor')) {
88: if ($liveConsultation->doctor_id !== getLogInUser()->doctor->id) {
89: return $this->sendError(__('messages.common.not_allow__assess_record'));
90: }
91: }
92: return $this->sendResponse($liveConsultation,
93: __('messages.flash.live_consultation_retrieved'));
94: }
95: public function update(LiveConsultationRequest $request, LiveConsultation
96: $liveConsultation): JsonResponse
97: {
98: try {
99: $this->liveConsultationRepository->edit($request->all(), $liveConsultation);
100: return $this->sendSuccess(__('messages.flash.live_consultation_update'));
101: } catch (Exception $e) {
102: return $this->sendError($e->getMessage());
103: }
104: }
105: public function destroy(LiveConsultation $liveConsultation): JsonResponse
106: {
107: if (getLogInUser()->hasrole('doctor')) {
108: if ($liveConsultation->doctor_id !== getLogInUser()->doctor->id) {
109: return $this->sendError(__('messages.common.not_allow__assess_record'));
110: }
111: }
112: try {
113: $this->zoomRepository->destroyZoomMeeting($liveConsultation->meeting_id);
114: $liveConsultation->delete();
115: return $this->sendSuccess(__('messages.flash.live_consultation_delete'));
116: } catch (Exception $e) {
117: return $this->sendError($e->getMessage());
118: }
119: }
120: public function getChangeStatus(Request $request): JsonResponse
121: {
122: $liveConsultation = LiveConsultation::findOrFail($request->get('id'));
123: $status = null;
124: if ($request->get('statusId') == LiveConsultation::STATUS_AWAITED) {
125: $status = LiveConsultation::STATUS_AWAITED;
126: } elseif ($request->get('statusId') == LiveConsultation::STATUS_CANCELLED) {
127: $status = LiveConsultation::STATUS_CANCELLED;
128: } else {
129: $status = LiveConsultation::STATUS_FINISHED;
130: }
131: $liveConsultation->update([
132: 'status' => $status,
133: ]);
134: return $this->sendsuccess(__('messages.flash.status_change'));
135: }
136: public function getLiveStatus(LiveConsultation $liveConsultation)
137: {
138: if (getLogInUser()->hasrole('patient')) {
139: if ($liveConsultation->patient_id !== getLogInUser()->patient->id) {
140: return $this->sendError(__('messages.common.not_allow__assess_record'));
141: }
142: }
143: if (getLogInUser()->hasrole('doctor')) {
144: if ($liveConsultation->doctor_id !== getLogInUser()->doctor->id) {
145: return $this->sendError(__('messages.common.not_allow__assess_record'));
146: }
147: }
148: $data['liveConsultation'] =
LiveConsultation::with('user')->find($liveConsultation->id);
149: /** @var ZoomRepository $zoomRepo */
150: $zoomRepo = App::make(ZoomRepository::class, ['createdBy' =>
151: $liveConsultation->created_by]);
152: $data['zoomLiveData'] = $zoomRepo->zoomGet(
153: $liveConsultation->meeting_id
154: );
155: return $this->sendResponse($data,
__('messages.live_status_retrieved_successfully'));
156: }
157: public function zoomCallback(Request $request): RedirectResponse
158: {
159: /** $zoomRepo Zoom */
160: $zoomRepo = FacadesApp::make(ZoomRepository::class);
161: $connected = $zoomRepo->connectWithZoom($request->get('code'));
162: if ($connected) {
163: Flash::success(__('messages.common.connected_zoom'));
164: return redirect(route('doctors.live-consultations.index'));
165: }
166: return redirect(route('doctors.live-consultations.index'));
167: }
168: public function zoomCredential(int $id): JsonResponse
169: {
170: try {
171: $data = UserZoomCredential::where('user_id', $id)->first();
172: return $this->sendResponse($data,
__('messages.flash.user_zoom_credential_retrieved'));
173: } catch (Exception $e) {
174: return $this->sendError($e->getMessage());
175: }
176: }
177: public function zoomCredentialCreate(CreateZoomCredentialRequest $request):
JsonResponse
178: {
179: try {
180: $this->liveConsultationRepository->createUserZoom($request->all());
181: return $this->sendSuccess(__('messages.flash.user_zoom_credential_saved'));
182: } catch (Exception $e) {
183: return $this->sendError($e->getMessage());
184: }
185: }
186: /**
187: * [Description for connectWithZoom]
188: *
189: * @return [type]
190: */
191: public function connectWithZoom(Request $request): RedirectResponse
192: {
193: $userZoomCredential = UserZoomCredential::where('user_id',
getLogInUserId())->first();
194: if ($userZoomCredential == null) {
195: return redirect()->back()->withErrors(__('messages.common.zoom_credentials'));
196: }
197: $clientID = $userZoomCredential->zoom_api_key;
198: $callbackURL = config('app.zoom_callback');
199: $url =
200: "https://zoom.us/oauth/authorize?client_id=$clientID&response_type=code&redirect_uri
=$callbackURL";
201: return redirect($url);
202: }
203: }
[Http > Controllers > MedicineBillController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\CreateMedicineBillRequest;
4: use App\Http\Requests\CreatePatientRequest;
5: use App\Http\Requests\UpdateMedicineBillRequest;
6: use App\Models\Category;
7: use App\Models\Medicine;
8: use App\Models\MedicineBill;
9: use App\Models\SaleMedicine;
10: use App\Repositories\DoctorRepository;
11: use App\Repositories\MedicineBillRepository;
12: use App\Repositories\MedicineRepository;
13: use App\Repositories\PatientRepository;
14: use App\Repositories\PrescriptionRepository;
15: use \PDF;
16: use Illuminate\Http\JsonResponse;
17: use Illuminate\Http\RedirectResponse;
18: use Illuminate\Http\Response;
19: use Illuminate\Support\Facades\Redirect;
20: use Illuminate\View\View;
21: use Laracasts\Flash\Flash;
22: class MedicineBillController extends AppBaseController
23: {
24: /* @var PrescriptionRepository
25: @var DoctorRepository
26: */
27: private $prescriptionRepository;
28: private $medicineRepository;
29: private $patientRepository;
30: private $medicineBillRepository;
31: public function __construct(
32: PrescriptionRepository $prescriptionRepo,
33: MedicineRepository $medicineRepository,
34: PatientRepository $patientRepo,
35: MedicineBillRepository $medicineBillRepository,
36: ) {
37: $this->prescriptionRepository = $prescriptionRepo;
38: $this->medicineRepository = $medicineRepository;
39: $this->patientRepository = $patientRepo;
40: $this->medicineBillRepository = $medicineBillRepository;
41: }
42: /**
43: * Display a listing of the resource.
44: */
45: public function index(): View
46: {
47: return view('medicine-bills.index');
48: }
49: /**
50: * Show the form for creating a new resource.
51: */
52: public function create(): View
53: {
54: $patients = $this->prescriptionRepository->getPatients();
55: $doctors = $this->prescriptionRepository->getDoctors();
56: $medicines = $this->prescriptionRepository->getMedicines();
57: $data = $this->medicineRepository->getSyncList();
58: $medicineList = $this->medicineRepository->getMedicineList();
59: $mealList = $this->medicineRepository->getMealList();
60: $medicineCategories = $this->medicineBillRepository->getMedicinesCategoriesData();
61: $medicineCategoriesList = $this->medicineBillRepository->getMedicineCategoriesList();
62: return view('medicine-bills.create',
63: compact('patients', 'doctors', 'medicines', 'medicineList', 'mealList',
64: 'medicineCategoriesList', 'medicineCategories'))->with($data);
65: }
66: /**
67: * Store a newly created resource in storage.
68: */
69: public function store(CreateMedicineBillRequest $request): RedirectResponse
70: {
71: $input = $request->all();
72: if (empty($input['medicine'])) {
73: flash::error(__('messages.medicine_bills.medicine_not_selected'));
74: return Redirect::route('medicine-bills.create');
75: }
76: $arr = collect($input['medicine']);
77: $duplicateIds = $arr->duplicates();
78: $input['payment_status'] = isset($input['payment_status']) ? 1 : 0;
79: foreach ($input['medicine'] as $key => $value) {
80: $medicine = Medicine::find($input['medicine'][$key]);
81: if (! empty($duplicateIds)) {
82: foreach ($duplicateIds as $key => $value) {
83: $medicine = Medicine::find($duplicateIds[$key]);
84: Flash::error(__('messages.medicine_bills.duplicate_medicine'));
85: return Redirect::route('medicine-bills.create');
86: }
87: }
88: $qty = $input['quantity'][$key];
89: if ($medicine->available_quantity < $qty) {
90: $available = $medicine->available_quantity == null ? 0 :
$medicine->available_quantity;
91: Flash::error(__('messages.medicine_bills.available_quantity').' '.$medicine->name.'
92: '.__('messages.medicine_bills.is').' '.$available.'.');
93: return Redirect::route('medicine-bills.create');
94: }
95: }
96: // dd($input);
97: $medicineBill = MedicineBill::create([
98: 'bill_number' => 'BIL'.generateUniqueBillNumber(),
99: 'patient_id' => $input['patient_id'],
100: 'net_amount' => $input['net_amount'],
101: 'discount' => $input['discount'],
102: 'payment_status' => $input['payment_status'],
103: 'payment_type' => $input['payment_type'],
104: 'note' => $input['note'],
105: 'total' => $input['total'],
106: 'tax_amount' => $input['tax'],
107: 'payment_note' => $input['payment_note'],
108: 'model_type' => \App\Models\MedicineBill::class,
109: 'bill_date' => $input['bill_date'],
110: ]);
111: $medicineBill->update([
112: 'model_id' => $medicineBill->id,
113: ]);
114: if ($input['category_id']) {
115: foreach ($input['category_id'] as $key => $value) {
116: $medicine = Medicine::find($input['medicine'][$key]);
117: $tax = $input['tax_medicine'][$key] == null ? $input['tax_medicine'][$key] : 0;
118: SaleMedicine::create([
119: 'medicine_bill_id' => $medicineBill->id,
120: 'medicine_id' => $medicine->id,
121: 'sale_price' => $input['sale_price'][$key],
122: 'expiry_date' => $input['expiry_date'][$key],
123: 'sale_quantity' => $input['quantity'][$key],
124: 'tax' => $tax,
125: ]);
126: if ($input['payment_status'] == 1) {
127: $medicine->update([
128: 'available_quantity' => $medicine->available_quantity - $input['quantity'][$key],
129: ]);
130: }
131: }
132: Flash::success(__('messages.medicine_bills.medicine_bill').'
133: '.__('messages.medicine.saved_successfully'));
134: return Redirect::route('medicine-bills.index');
135: }
136: }
137: /**
138: * Display the specified resource.
139: *
140: * @param int $id
141: */
142: public function show(MedicineBill $medicineBill): View
143: {
144: $medicineBill->load(['saleMedicine.medicine']);
145: return view('medicine-bills.show', compact('medicineBill'));
146: }
147: /**
148: * Show the form for editing the specified resource.
149: */
150: public function edit(MedicineBill $medicineBill): View
151: {
152: $medicineBill->load(['saleMedicine.medicine.category',
153: 'saleMedicine.medicine.purchasedMedicine', 'patient', 'doctor']);
154: $patients = $this->prescriptionRepository->getPatients();
155: $doctors = $this->prescriptionRepository->getDoctors();
156: $medicines = $this->prescriptionRepository->getMedicines();
157: $data = $this->medicineRepository->getSyncList();
158: $medicineList = $this->medicineRepository->getMedicineList();
159: $mealList = $this->medicineRepository->getMealList();
160: $medicineCategories = $this->medicineBillRepository->getMedicinesCategoriesData();
161: $medicineCategoriesList =
$this->medicineBillRepository->getMedicineCategoriesList();
162: return view('medicine-bills.edit',
163: compact('patients', 'doctors', 'medicines', 'medicineList', 'mealList',
'medicineBill',
164: 'medicineCategoriesList', 'medicineCategories'))->with($data);
165: }
166: /**
167: * Update the specified resource in storage.
168: *
169: * @param int $id
170: * @return \Illuminate\Http\Response
171: */
172: public function update(MedicineBill $medicineBill, UpdateMedicineBillRequest
$request)
173: {
174: $input = $request->all();
175: if (empty($input['medicine']) && $input['payment_status'] == false) {
176: return $this->sendError(__('messages.medicine_bills.medicine_not_selected'));
177: }
178: $this->medicineBillRepository->update($medicineBill, $input);
179: return $this->sendSuccess(__('messages.medicine_bills.medicine_bill').'
180: '.__('messages.medicine.saved_successfully'));
181: }
182: /**
183: * Remove the specified resource from storage.
184: *
185: * * @return \Illuminate\Http\Response
186: */
187: public function destroy(MedicineBill $medicineBill)
188: {
189: $medicineBill->saleMedicine()->delete();
190: $medicineBill->delete();
191: return $this->sendSuccess(__('messages.medicine_bills.medicine_bill').'
192: '.__('messages.common.deleted_successfully'));
193: }
194: /** Store a newly created Patient in storage.
195: */
196: public function storePatient(CreatePatientRequest $request): JsonResponse
197: {
198: $input = $request->all();
199: $input['status'] = isset($input['status']) ? 1 : 0;
200: $this->patientRepository->store($input);
201: $this->patientRepository->createNotification($input);
202: $patients = $this->prescriptionRepository->getPatients();
203: return $this->sendResponse($patients, __('messages.flash.Patient_saved'));
204: }
205: public function convertToPDF($id): Response
206: {
207: $data = $this->prescriptionRepository->getSettingList();
208: $medicineBill = MedicineBill::with(['saleMedicine.medicine'])->where('id',
$id)->first();
209: $pdf = Pdf::loadView('medicine-bills.medicine_bill_pdf', compact('medicineBill',
'data'));
210: return $pdf->stream('medicine-bill.pdf');
211: }
212: public function getMedicineCategory(Category $category): JsonResponse
213: {
214: $data = [];
215: $data['category'] = $category;
216: $data['medicine'] = Medicine::whereCategoryId($category->id)->pluck('name',
217: 'id')->toArray();
218: return $this->sendResponse($data, 'retrieved');
219: }
220: }
[Http > Controllers > MedicineController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\CreateMedicineRequest;
4: use App\Http\Requests\UpdateMedicineRequest;
5: use App\Models\Medicine;
6: use App\Models\PurchasedMedicine;
7: use App\Models\SaleMedicine;
8: use App\Repositories\MedicineRepository;
9: use Exception;
10: use Flash;
11: use Illuminate\Contracts\View\Factory;
12: use Illuminate\Http\JsonResponse;
13: use Illuminate\Http\RedirectResponse;
14: use Illuminate\Http\Request;
15: use Illuminate\Routing\Redirector;
16: use Illuminate\View\View;
17: use Response;
18: class MedicineController extends AppBaseController
19: {
20: /** @var MedicineRepository */
21: private $medicineRepository;
22: public function __construct(MedicineRepository $medicineRepo)
23: {
24: $this->medicineRepository = $medicineRepo;
25: }
26: /**
27: * Display a listing of the Medicine.
28: *
29: * @param Request $request
30: * @return Factory|View|Response
31: *
32: * @throws Exception
33: */
34: public function index(): View
35: {
36: return view('medicines.index');
37: }
38: /**
39: * Show the form for creating a new Medicine.
40: *
41: * @return Factory|View
42: */
43: public function create(): View
44: {
45: $data = $this->medicineRepository->getSyncList();
46: return view('medicines.create')->with($data);
47: }
48: /**
49: * Store a newly created Medicine in storage.
50: *
51: * @return RedirectResponse|Redirector
52: */
53: public function store(CreateMedicineRequest $request): RedirectResponse
54: {
55: $input = $request->all();
56: $this->medicineRepository->create($input);
57: Flash::success(__('messages.medicine.medicine').'
58: '.__('messages.medicine.saved_successfully'));
59: return redirect(route('medicines.index'));
60: }
61: /**
62: * Display the specified Medicine.
63: *
64: * @return Factory|View
65: */
66: public function show(Medicine $medicine): View
67: {
68: $medicine->brand;
69: $medicine->category;
70: return view('medicines.show')->with('medicine', $medicine);
71: }
72: /**
73: * Show the form for editing the specified Medicine.
74: *
75: * @return Factory|View
76: */
77: public function edit(Medicine $medicine): View
78: {
79: $data = $this->medicineRepository->getSyncList();
80: $data['medicine'] = $medicine;
81: return view('medicines.edit')->with($data);
82: }
83: /**
84: * Update the specified Medicine in storage.
85: *
86: * @return RedirectResponse|Redirector
87: */
88: public function update(Medicine $medicine, UpdateMedicineRequest $request):
89: RedirectResponse
90: {
91: $this->medicineRepository->update($request->all(), $medicine->id);
92: Flash::success(__('messages.medicine.medicine').'
93: '.__('messages.medicine.updated_successfully'));
94: return redirect(route('medicines.index'));
95: }
96: /**
97: * Remove the specified Medicine from storage.
98: *
99: *
100: * @throws Exception
101: */
102: public function destroy(Medicine $medicine): JsonResponse
103: {
104: if (! canAccessRecord(Medicine::class, $medicine->id)) {
105: return $this->sendError(__('messages.flash.medicine_not_found'));
106: }
107: $purchaseMedicine = PurchasedMedicine::whereMedicineId($medicine->id)->first();
108: $saleMedicine = SaleMedicine::whereMedicineId($medicine->id)->first();
109: if (isset($purchaseMedicine) && ! empty($purchaseMedicine)) {
110: $purchaseMedicine->delete();
111: }
112: if (isset($saleMedicine) && ! empty($saleMedicine)) {
113: $saleMedicine->delete();
114: }
115: $this->medicineRepository->delete($medicine->id);
116: return $this->sendSuccess(__('messages.medicine.medicine').'
117: '.__('messages.medicine.deleted_successfully'));
118: }
119: /**
120: * @throws \Gerardojbaez\Money\Exceptions\CurrencyException
121: */
122: public function showModal(Medicine $medicine): JsonResponse
123: {
124: $medicine->load(['brand', 'category']);
125: $currency = $medicine->currency_symbol ? strtoupper($medicine->currency_symbol) :
126: strtoupper(getCurrentCurrency());
127: $medicine = [
128: 'name' => $medicine->name,
129: 'brand_name' => $medicine->brand->name,
130: 'category_name' => $medicine->category->name,
131: 'salt_composition' => $medicine->salt_composition,
132: 'side_effects' => $medicine->side_effects,
133: 'created_at' => $medicine->created_at,
134: 'selling_price' => getCurrencyFormat(getCurrencyCode(), $medicine->buying_price),
135: 'buying_price' => getCurrencyFormat(getCurrencyCode(), $medicine->buying_price),
136: 'updated_at' => $medicine->updated_at,
137: 'description' => $medicine->description,
138: 'quantity' => $medicine->quantity,
139: 'available_quantity' => $medicine->available_quantity,
140: ];
141: return $this->sendResponse($medicine,
142: __('messages.medicine.medicine_retrieved_successfully'));
143: }
144: public function checkUseOfMedicine(Medicine $medicine)
145: {
146: $SaleModel = [
147: SaleMedicine::class,
148: PurchasedMedicine::class,
149: ];
150: $result['result'] = canDelete($SaleModel, 'medicine_id', $medicine->id);
151: $result['id'] = $medicine->id;
152: if ($result) {
153: return $this->sendResponse($result,
154: __('messages.medicine_bills.the_medicine_already_in_use'));
155: }
156: return $this->sendResponse($result, __('messages.medicine.no_use'));
157: }
158: }
[Http > Controllers > NotificationController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Models\Notification;
4: use Carbon\Carbon;
5: use Illuminate\Http\JsonResponse;
6: class NotificationController extends AppBaseController
7: {
8: public function readNotification(Notification $notification): JsonResponse
9: {
10: $notification->read_at = Carbon::now();
11: $notification->save();
12: return $this->sendSuccess(__('messages.flash.notification_read'));
13: }
14: public function readAllNotification(): JsonResponse
15: {
16: Notification::whereReadAt(null)->where('user_id',
17: getLogInUserId())->update(['read_at' => Carbon::now()]);
18: return $this->sendSuccess(__('messages.flash.all_notification_read'));
19: }
20: }
[Http > Controllers > PatientAppointmentController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Models\Appointment;
4: use Illuminate\Contracts\Foundation\Application;
5: use Illuminate\Contracts\View\Factory;
6: use Illuminate\Contracts\View\View;
7: use Illuminate\Support\Arr;
8: class PatientAppointmentController extends AppBaseController
9: {
10: /**
11: * @return Application|Factory|View
12: */
13: public function index(): \Illuminate\View\View
14: {
15: $allPaymentStatus = getAllPaymentStatus();
16: $paymentStatus = Arr::except($allPaymentStatus, [Appointment::MANUALLY]);
17: $paymentGateway = getPaymentGateway();
18: return view('patients.appointments.index', compact('paymentStatus',
'paymentGateway'));
19: }
20: }
[Http > Controllers > PatientController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use Flash;
4: use Exception;
5: use Carbon\Carbon;
6: use App\Models\User;
7: use App\Models\Visit;
8: use App\Models\Patient;
9: use App\Models\Appointment;
10: use App\Models\Transaction;
11: use Illuminate\Http\Request;
12: use Illuminate\Http\JsonResponse;
13: use Illuminate\Routing\Redirector;
14: use Illuminate\Support\Facades\DB;
15: use Illuminate\Contracts\View\View;
16: use App\DataTables\PatientDataTable;
17: use Illuminate\Http\RedirectResponse;
18: use Illuminate\Contracts\View\Factory;
19: use App\Repositories\PatientRepository;
20: use Yajra\DataTables\Facades\DataTables;
21: use App\Http\Requests\CreatePatientRequest;
22: use App\Http\Requests\UpdatePatientRequest;
23: use Illuminate\Contracts\Foundation\Application;
24: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
25: class PatientController extends AppBaseController
26: {
27: /** @var PatientRepository */
28: private $patientRepository;
29: public function __construct(PatientRepository $patientRepo)
30: {
31: $this->patientRepository = $patientRepo;
32: }
33: /**
34: * Display a listing of the Patient.
35: *
36: * @return Application|Factory|View
37: */
38: public function index(): \Illuminate\View\View
39: {
40: return view('patients.index');
41: }
42: /**
43: * Show the form for creating a new Patient.
44: *
45: * @return Application|Factory|View
46: */
47: public function create(): \Illuminate\View\View
48: {
49: $data = $this->patientRepository->getData();
50: return view('patients.create', compact('data'));
51: }
52: /**
53: * Store a newly created Patient in storage.
54: *
55: * @return Application|Redirector|RedirectResponse
56: */
57: public function store(CreatePatientRequest $request): RedirectResponse
58: {
59: $input = $request->all();
60: $patient = $this->patientRepository->store($input);
61: Flash::success(__('messages.flash.patient_create'));
62: return redirect(route('patients.index'));
63: }
64: /**
65: * Display the specified Patient.
66: *
67: * @return Application|Factory|View|RedirectResponse
68: */
69: public function show(Patient $patient)
70: {
71: if (getLogInUser()->hasRole('doctor')) {
72: $doctor =
73: Appointment::wherePatientId($patient->id)->whereDoctorId(getLogInUser()->doctor->id);
74: if (! $doctor->exists()) {
75: return redirect()->back();
76: }
77: }
78: if (empty($patient)) {
79: Flash::error(__('messages.flash.patient_not_found'));
80: return redirect(route('patients.index'));
81: }
82: $patient = $this->patientRepository->getPatientData($patient);
83: $appointmentStatus = Appointment::ALL_STATUS;
84: $todayDate = Carbon::now()->format('Y-m-d');
85: $data['todayAppointmentCount'] =
86: Appointment::wherePatientId($patient['id'])->where('date', '=',
87: $todayDate)->count();
88: $data['upcomingAppointmentCount'] =
89: Appointment::wherePatientId($patient['id'])->where('date', '>',
90: $todayDate)->count();
91: $data['completedAppointmentCount'] =
92: Appointment::wherePatientId($patient['id'])->where('date', '<',
93: $todayDate)->count();
94: return view('patients.show', compact('patient', 'appointmentStatus', 'data'));
95: }
96: /**
97: * Show the form for editing the specified Patient.
98: *
99: * @return Application|Factory|View
100: */
101: public function edit(Patient $patient)
102: {
103: if (empty($patient)) {
104: Flash::error(__('messages.flash.patient_not_found'));
105: return redirect(route('patients.index'));
106: }
107: $data = $this->patientRepository->getData();
108: unset($data['patientUniqueId']);
109: return view('patients.edit', compact('data', 'patient'));
110: }
111: /**
112: * Update the specified Patient in storage.
113: *
114: * @return Application|Redirector|RedirectResponse
115: */
116: public function update(Patient $patient, UpdatePatientRequest $request):
RedirectResponse
117: {
118: $input = request()->except(['_method', '_token', 'patient_unique_id']);
119: if (empty($patient)) {
120: Flash::error(__('messages.flash.patient_not_found'));
121: return redirect(route('patients.index'));
122: }
123: $patient = $this->patientRepository->update($input, $patient);
124: Flash::success(__('messages.flash.patient_update'));
125: return redirect(route('patients.index'));
126: }
127: /**
128: * Remove the specified Patient from storage.
129: */
130: public function destroy(Patient $patient): JsonResponse
131: {
132: $existAppointment = Appointment::wherePatientId($patient->id)
133: ->whereNotIn('status', [Appointment::CANCELLED, Appointment::CHECK_OUT])
134: ->exists();
135: $existVisit = Visit::wherePatientId($patient->id)->exists();
136: $transactions = Transaction::whereUserId($patient->user_id)->exists();
137: if ($existAppointment || $existVisit || $transactions) {
138: return $this->sendError(__('messages.flash.patient_used'));
139: }
140: try {
141: DB::beginTransaction();
142: $patient->delete();
143: $patient->media()->delete();
144: $patient->user()->delete();
145: $patient->address()->delete();
146: DB::commit();
147: return $this->sendSuccess(__('messages.flash.patient_delete'));
148: } catch (Exception $e) {
149: throw new UnprocessableEntityHttpException($e->getMessage());
150: }
151: }
152: /**
153: * @return Application|RedirectResponse|Redirector
154: *
155: * @throws Exception
156: */
157: public function patientAppointment(Patient $patient, Request $request)
158: {
159: if ($request->ajax()) {
160: return DataTables::of((new PatientDataTable())->getAppointment($request->only([
161: 'status', 'patientId', 'filter_date',
162: ])))->make(true);
163: }
164: return redirect(route('patients.index'));
165: }
166: public function deleteOldPatient()
167: {
168: $patients = Patient::pluck('user_id')->toArray();
169: User::whereType(User::PATIENT)->whereNotIn('id', $patients)->delete();
170: }
171: }
[Http > Controllers > PatientQrCodeController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use Illuminate\Http\Request;
4: use App\Models\Patient;
5: use App\Models\Appointment;
6: use Carbon\Carbon;
7: use Flash;
8: use App\Repositories\PatientRepository;
9: use Symfony\Contracts\Service\Attribute\Required;
10: use App\Models\Visit;
11: class PatientQrCodeController extends AppBaseController
12: {
13: private $patientRepository;
14: public function __construct(PatientRepository $patientRepo)
15: {
16: $this->patientRepository = $patientRepo;
17: }
18: public function show($id)
19: {
20: $patient = Patient::with(['user.address', 'appointments',
21: 'address'])->where('patient_unique_id',$id)->first();
22: if (empty($id)) {
23: Flash::error(__('messages.flash.patient_not_found'));
24: return redirect(route('patients.index'));
25: }
26: $appointmentStatus = Appointment::ALL_STATUS;
27: $appointment = Appointment::with('doctor')->where('patient_id', '=',
$patient->id)->get();
28: $visit = Visit::with(['doctor.user', 'patient.user'])->where('patient_id', '=',
29: $patient->id)->get();
30: $todayDate = Carbon::now()->format('Y-m-d');
31: $data['todayAppointmentCount'] =
32: Appointment::wherePatientId($patient['id'])->where('date', '=',
33: $todayDate)->count();
34: $data['upcomingAppointmentCount'] =
35: Appointment::wherePatientId($patient['id'])->where('date', '>',
36: $todayDate)->count();
37: $data['completedAppointmentCount'] =
38: Appointment::wherePatientId($patient['id'])->where('date', '<',
39: $todayDate)->count();
40: return view('fronts.patient_qr_code.show',
41: compact('patient','appointment','appointmentStatus', 'data','visit'))->with([
42: 'book' => Appointment::BOOKED,
43: 'checkIn' => Appointment::CHECK_IN,
44: 'checkOut' => Appointment::CHECK_OUT,
45: 'cancel' => Appointment::CANCELLED,
46: ]);
47: }
48: }
[Http > Controllers > PatientVisitController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Models\Visit;
4: use App\Repositories\PatientVisitRepository;
5: use Illuminate\Contracts\Foundation\Application;
6: use Illuminate\Contracts\View\Factory;
7: use Illuminate\Contracts\View\View;
8: use Illuminate\Http\RedirectResponse;
9: class PatientVisitController extends Controller
10: {
11: /** @var PatientVisitRepository */
12: private $patientVisitRepository;
13: public function __construct(PatientVisitRepository $patientVisitRepository)
14: {
15: $this->patientVisitRepository = $patientVisitRepository;
16: }
17: /**
18: * @return Application|Factory|View
19: */
20: public function index(): \Illuminate\View\View
21: {
22: return view('patient_visits.index');
23: }
24: /**
25: * @return Application|Factory|View|RedirectResponse
26: */
27: public function show($id)
28: {
29: if (getLogInUser()->hasRole('patient')) {
30: $patient = Visit::whereId($id)->wherePatientId(getLogInUser()->patient->id);
31: if (! $patient->exists()) {
32: return redirect()->back();
33: }
34: }
35: $visit = $this->patientVisitRepository->getShowData($id);
36: return view('patient_visits.show', compact('visit'));
37: }
38: }
[Http > Controllers > PaypalController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Models\Appointment;
4: use App\Models\Notification;
5: use App\Models\Patient;
6: use App\Models\Transaction;
7: use Flash;
8: use Illuminate\Http\JsonResponse;
9: use Illuminate\Http\RedirectResponse;
10: use Illuminate\Http\Request;
11: use PayPalHttp\HttpException;
12: use Srmklive\PayPal\Services\PayPal as PayPalClient;
13: class PaypalController extends Controller
14: {
15: public function onBoard(Request $request): JsonResponse
16: {
17: $appointment = Appointment::whereId($request->appointmentId)->first();
18: $provider = new PayPalClient;
19: $provider->getAccessToken();
20: $data = [
21: 'intent' => 'CAPTURE',
22: 'purchase_units' => [
23: [
24: 'reference_id' => $appointment->id,
25: 'amount' => [
26: 'value' => $appointment->payable_amount,
27: 'currency_code' => getCurrencyCode(),
28: ],
29: ],
30: ],
31: 'application_context' => [
32: 'cancel_url' => route('paypal.failed'),
33: 'return_url' => route('paypal.success'),
34: ],
35: ];
36: $order = $provider->createOrder($data);
37: return response()->json(['link' => $order['links'][1]['href'], 'status' => 200]);
38: }
39: public function failed(): RedirectResponse
40: {
41: Flash::error(__('messages.flash.appointment_created_payment_not_complete'));
42: if (! getLogInUser()) {
43: return redirect(route('medicalAppointment'));
44: }
45: if (getLogInUser()->hasRole('patient')) {
46: return redirect(route('patients.patient-appointments-index'));
47: }
48: return redirect(route('appointments.index'));
49: }
50: public function success(Request $request): RedirectResponse
51: {
52: $clientId = config('payments.paypal.client_id');
53: $clientSecret = config('payments.paypal.client_secret');
54: $mode = config('payments.paypal.mode');
55: $provider = new PayPalClient; // To use express checkout.
56: $provider->getAccessToken();
57: $token = $request->get('token');
58: $orderInfo = $provider->showOrderDetails($token);
59: try {
60: // Call API with your client and get a response for your call
61: $response = $provider->capturePaymentOrder($token);
62: // If call returns body in response, you can get the deserialized version from the
result
63: attribute of the response
64: $appointmentID = $response['purchase_units'][0]['reference_id'];
65: // $transactionID = $response->result->id;
66: $appointment = Appointment::whereId($appointmentID)->first();
67: $patient = Patient::with('user')->whereId($appointment->patient_id)->first();
68: $transaction = [
69: 'user_id' => $patient->user->id,
70: 'transaction_id' => $response['purchase_units'][0]['payments']['captures'][0]['id'],
71: 'appointment_id' => $appointment['appointment_unique_id'],
72: 'amount' => intval($appointment['payable_amount']),
73: 'type' => Appointment::PAYPAL,
74: 'meta' => json_encode($response),
75: ];
76: Transaction::create($transaction);
77: $appointment->update([
78: 'payment_method' => Appointment::PAYPAL,
79: 'payment_type' => Appointment::PAID,
80: ]);
81: Flash::success(__('messages.flash.appointment_created_payment_complete'));
82: Notification::create([
83: 'title' => Notification::APPOINTMENT_PAYMENT_DONE_PATIENT_MSG,
84: 'type' => Notification::PAYMENT_DONE,
85: 'user_id' => $patient->user->id,
86: ]);
87: if (! getLogInUser()) {
88: return redirect(route('medicalAppointment'));
89: }
90: if (getLogInUser()->hasRole('patient')) {
91: return redirect(route('patients.patient-appointments-index'));
92: }
93: return redirect(route('appointments.index'));
94: } catch (HttpException $ex) {
95: echo $ex->statusCode;
96: print_r($ex->getMessage());
97: }
98: }
99: }
[Http > Controllers > PaystackController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Models\Appointment;
4: use App\Models\Notification;
5: use App\Models\Patient;
6: use App\Models\Transaction;
7: use App\Models\User;
8: use Flash;
9: use Illuminate\Contracts\Foundation\Application;
10: use Illuminate\Http\RedirectResponse;
11: use Illuminate\Http\Request;
12: use Illuminate\Routing\Redirector;
13: use Illuminate\Support\Facades\Redirect;
14: use Unicodeveloper\Paystack\Facades\Paystack;
15: class PaystackController extends Controller
16: {
17: /**
18: * @return mixed
19: */
20: public function redirectToGateway(Request $request)
21: {
22: $appointmentId = $request['appointmentData'];
23: $appointment = Appointment::whereId($appointmentId)->first();
24: $patientEmail = Patient::with('user')->whereId($appointment['patient_id'])->first();
25: $appointmentUniqueId = $appointment['appointment_unique_id'];
26: try {
27: $request->request->add([
28: 'email' => $patientEmail->user->email, // email of recipients
29: 'orderID' => $appointmentUniqueId, // anything
30: 'amount' => $appointment['payable_amount'] * 100,
31: 'quantity' => 1, // always 1
32: 'currency' => 'ZAR',
33: 'reference' => Paystack::genTranxRef(),
34: 'metadata' => json_encode(['appointmentId' => $appointmentId]), // this should be
related
35: data
36: ]);
37: return Paystack::getAuthorizationUrl()->redirectNow();
38: } catch (\Exception $e) {
39: return Redirect::back()->withMessage([
40: 'msg' => __('messages.flash.paystack_token_expired'),
41: 'type' => 'error',
42: ]);
43: }
44: }
45: /**
46: * @return Application|RedirectResponse|Redirector
47: */
48: public function handleGatewayCallback(Request $request): RedirectResponse
49: {
50: $paymentDetails = Paystack::getPaymentData();
51: $appointmentId = $paymentDetails['data']['metadata']['appointmentId'];
52: $appointment = Appointment::whereId($appointmentId)->first();
53: $patientId =
54: User::whereEmail($paymentDetails['data']['customer']['email'])->pluck('id')->first();
55: $transaction = [
56: 'user_id' => $patientId,
57: 'transaction_id' => $paymentDetails['data']['reference'],
58: 'appointment_id' => $appointment['appointment_unique_id'],
59: 'amount' => intval($appointment['payable_amount']),
60: 'type' => Appointment::PAYSTACK,
61: 'meta' => json_encode($paymentDetails['data']),
62: ];
63: Transaction::create($transaction);
64: $appointment->update([
65: 'payment_method' => Appointment::PAYSTACK,
66: 'payment_type' => Appointment::PAID,
67: ]);
68: Flash::success(__('messages.flash.appointment_created_payment_complete'));
69: $patient = Patient::whereUserId($patientId)->with('user')->first();
70: Notification::create([
71: 'title' => Notification::APPOINTMENT_PAYMENT_DONE_PATIENT_MSG,
72: 'type' => Notification::PAYMENT_DONE,
73: 'user_id' => $patient->user_id,
74: ]);
75: if (parse_url(url()->previous(), PHP_URL_PATH) == '/medical-appointment') {
76: return redirect(route('medicalAppointment'));
77: }
78: if (! getLogInUser()) {
79: return redirect(route('medical'));
80: }
81: if (getLogInUser()->hasRole('patient')) {
82: return redirect(route('patients.patient-appointments-index'));
83: }
84: return redirect(route('appointments.index'));
85: }
86: }
[Http > Controllers > PayTMController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use Anand\LaravelPaytmWallet\Facades\PaytmWallet;
4: use App\Http\Requests\CreatePaytmDetailRequest;
5: use App\Models\Appointment;
6: use App\Models\Doctor;
7: use App\Models\Notification;
8: use App\Models\Patient;
9: use App\Models\Transaction;
10: use App\Models\User;
11: use Flash;
12: use Illuminate\Contracts\Foundation\Application;
13: use Illuminate\Http\RedirectResponse;
14: use Illuminate\Http\Request;
15: use Illuminate\Routing\Redirector;
16: use Illuminate\Support\Facades\Auth;
17: use Illuminate\Support\Facades\Log;
18: use Illuminate\View\View;
19: /**
20: * Class PayTMController
21: */
22: class PayTMController extends AppBaseController
23: {
24: // display a form for payment
25: public function initiate(Request $request): View
26: {
27: $appointmentId = $request->appointmentId;
28: $appointment = Appointment::whereId($appointmentId)->first();
29: $doctor = Doctor::with('user')->whereId($appointment->doctor_id)->first();
30: $patient = Patient::with('user')->whereId($appointment->patient_id)->first();
31: return view('payments.paytm.index', compact('appointmentId', 'appointment', 'doctor',
32: 'patient'));
33: }
34: /**
35: * @return mixed
36: */
37: public function payment(CreatePaytmDetailRequest $request)
38: {
39: $input = $request->all();
40: $appointmentId = $request->appointmentId;
41: $appointment = Appointment::whereId($appointmentId)->first();
42: $patient = Patient::with('user')->whereId($appointment->patient_id)->first();
43: $payment = PaytmWallet::with('receive');
44: $loginUserId = getLogInUser() ? getLogInUserId() : '';
45: $payment->prepare([
46: 'order' => $appointmentId.'|'.$loginUserId.'|'.time(), // 1 should be your any data
id
47: 'user' => $patient['user']['id'], // any user id
48: 'mobile_number' => $input['mobile'],
49: 'email' => $input['email'], // your user email address
50: 'amount' => $appointment->payable_amount, // amount will be paid in INR.
51: 'callback_url' => route('paytm.callback'), // callback URL
52: ]);
53: return $payment->receive(); // initiate a new payment
54: }
55: /**
56: * Obtain the payment information.
57: *
58: * @return object
59: */
60: public function paymentCallback()
61: {
62: $transaction = PaytmWallet::with('receive');
63: $response = $transaction->response();
64: $order_id = $transaction->getOrderId(); // return a order id
65: $transaction->getTransactionId(); // return a transaction id
66: [$appointmentId, $loginUserId] = explode('|', $order_id);
67: // update the db data as per result from api call
68: if ($transaction->isSuccessful()) {
69: $appointment = Appointment::whereId($appointmentId)->first();
70: $patient = Patient::with('user')->whereId($appointment->patient_id)->first();
71: $transaction = [
72: 'user_id' => $patient->user->id,
73: 'transaction_id' => $response['TXNID'],
74: 'appointment_id' => $appointment['appointment_unique_id'],
75: 'amount' => $appointment['payable_amount'],
76: 'type' => Appointment::PAYTM,
77: 'meta' => json_encode($response),
78: ];
79: Transaction::create($transaction);
80: $appointment->update([
81: 'payment_method' => Appointment::PAYTM,
82: 'payment_type' => Appointment::PAID,
83: ]);
84: Flash::success(__('messages.flash.appointment_created_payment_complete'));
85: Notification::create([
86: 'title' => Notification::APPOINTMENT_PAYMENT_DONE_PATIENT_MSG,
87: 'type' => Notification::PAYMENT_DONE,
88: 'user_id' => $patient->user->id,
89: ]);
90: if ($loginUserId == User::ADMIN) {
91: Auth::loginUsingId($loginUserId);
92: return redirect(route('appointments.index'));
93: }
94: if ($loginUserId != '') {
95: Auth::loginUsingId($loginUserId);
96: return redirect(route('patients.patient-appointments-index'));
97: }
98: return redirect(route('medicalAppointment'));
99: } elseif ($transaction->isFailed()) {
100: Flash::error(__('messages.flash.appointment_created_payment_not_complete'));
101: if ($loginUserId == User::ADMIN) {
102: Auth::loginUsingId($loginUserId);
103: return redirect(route('appointments.index'));
104: }
105: if ($loginUserId != '') {
106: Auth::loginUsingId($loginUserId);
107: return redirect(route('patients.patient-appointments-index'));
108: }
109: return redirect(route('medicalAppointment'));
110: } else {
111: if ($transaction->isOpen()) {
112: Log::info('Open');
113: }
114: }
115: // $transaction->getResponseMessage(); //Get Response Message If Available
116: }
117: /**
118: * @return Application|RedirectResponse|Redirector
119: */
120: public function failed(): RedirectResponse
121: {
122: Flash::error(__('messages.flash.appointment_created_payment_not_complete'));
123: if (! getLogInUser()) {
124: return redirect(route('medicalAppointment'));
125: }
126: if (getLogInUser()->hasRole('patient')) {
127: return redirect(route('patients.patient-appointments-index'));
128: }
129: return redirect(route('appointments.index'));
130: }
131: }
[Http > Controllers > PrescriptionController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\CreateMedicineRequest;
4: use App\Http\Requests\CreatePrescriptionRequest;
5: use App\Http\Requests\UpdatePrescriptionRequest;
6: use App\Models\Appointment;
7: use App\Models\Medicine;
8: use App\Models\Prescription;
9: use App\Repositories\DoctorRepository;
10: use App\Repositories\MedicineRepository;
11: use App\Repositories\PrescriptionRepository;
12: use \PDF;
13: use Exception;
14: use Flash;
15: use Illuminate\Contracts\View\Factory;
16: use Illuminate\Http\JsonResponse;
17: use Illuminate\Http\RedirectResponse;
18: use Illuminate\Routing\Redirector;
19: use Illuminate\Support\Facades\Redirect;
20: use Illuminate\View\View;
21: class PrescriptionController extends AppBaseController
22: {
23: /** @var PrescriptionRepository
24: * @var DoctorRepository
25: */
26: private $prescriptionRepository;
27: private $medicineRepository;
28: public function __construct(
29: PrescriptionRepository $prescriptionRepo,
30: MedicineRepository $medicineRepository
31: ) {
32: $this->prescriptionRepository = $prescriptionRepo;
33: $this->medicineRepository = $medicineRepository;
34: }
35: /**
36: * Show the form for creating a new Prescription.
37: *
38: * @return Factory|View
39: */
40: public function create($appointmentId): View
41: {
42: $patients = $this->prescriptionRepository->getPatients();
43: $doctors = $this->prescriptionRepository->getDoctors();
44: $medicines = $this->prescriptionRepository->getMedicines();
45: $medicinesQuantity = $this->prescriptionRepository->getMedicinesQuantity();
46: $data = $this->medicineRepository->getSyncList();
47: $medicineList = $this->medicineRepository->getMedicineList();
48: $mealList = $this->medicineRepository->getMealList();
49: $doseDuration = $this->medicineRepository->getDoseDurationList();
50: $doseInverval = $this->medicineRepository->getDoseInterValList();
51: $appointment = Appointment::with('doctor','patient')->find($appointmentId);
52: return view('prescriptions.create',
53: compact('patients', 'doctors','appointment', 'medicines','medicinesQuantity',
54: 'medicineList', 'mealList', 'doseDuration', 'doseInverval',
55: 'appointmentId'))->with($data);
56: }
57: /**
58: * Store a newly created Prescription in storage.
59: *
60: * @return RedirectResponse|Redirector
61: */
62: public function store(CreatePrescriptionRequest $request): RedirectResponse
63: {
64: $input = $request->all();
65: $input['status'] = isset($input['status']) ? 1 : 0;
66: if (isset($input['medicine'])) {
67: $arr = collect($input['medicine']);
68: $duplicateIds = $arr->duplicates();
69: foreach ($input['medicine'] as $key => $value) {
70: $medicine = Medicine::find($input['medicine'][$key]);
71: if (! empty($duplicateIds)) {
72: foreach ($duplicateIds as $key => $value) {
73: $medicine = Medicine::find($duplicateIds[$key]);
74: Flash::error(__('messages.prescription.not_add_duplicate_medicines'));
75: return Redirect::back();
76: }
77: }
78: }
79: foreach ($input['medicine'] as $key => $value) {
80: $medicine = Medicine::find($input['medicine'][$key]);
81: $qty = $input['day'][$key] * $input['dose_interval'][$key];
82: if ($medicine->available_quantity < $qty) {
83: $available = $medicine->available_quantity == null ? 0 :
$medicine->available_quantity;
84: // Flash::error('The available quantity of '.$medicine->name.' is '.$available.'.');
85:
86: Flash::error(__('messages.prescription.available_quantity_of').$medicine->name.__('me
ssages.prescription.is').$available.'.');
87: return Redirect::back();
88: }
89: }
90: }
91: $prescription = $this->prescriptionRepository->create($input);
92: $showRoute = isRole('doctor') ? 'doctors.appointment.detail' : (isRole('patient') ?
93: 'patients.appointment.detail' : 'appointments.show');
94: $this->prescriptionRepository->createPrescription($input, $prescription);
95: Flash::success(__('messages.prescription.prescription_saved'));
96: return redirect(route($showRoute, $input['appointment_id']));
97: }
98: /**
99: * @return Factory|RedirectResponse|Redirector|View
100: */
101: public function show(Prescription $prescription)
102: {
103: if (! canAccessRecord(Prescription::class, $prescription->id)) {
104: Flash::error(__('messages.flash.not_allow_access_record'));
105: return Redirect::back();
106: }
107: $prescription = $this->prescriptionRepository->find($prescription->id);
108: if (empty($prescription)) {
109: Flash::error(__('messages.flash.prescription_not_found'));
110: return Redirect::back();
111: }
112: return view('prescriptions.show')->with('prescription', $prescription);
113: }
114: /**
115: * @return
116: \Illuminate\Contracts\Foundation\Application|Factory|\Illuminate\Contracts\View\View
|RedirectResponse
117: */
118: public function edit($appointmentId, Prescription $prescription)
119: {
120: if (! canAccessRecord(Prescription::class, $prescription->id)) {
121: Flash::error(__('messages.flash.not_allow_access_record'));
122: return Redirect::back();
123: }
124: if (getLogInUser()->hasRole('Doctor')) {
125: $patientPrescriptionHasDoctor =
126: Prescription::whereId($prescription->id)->whereDoctorId(getLogInUser()->owner_id)->e
xists();
127: if (! $patientPrescriptionHasDoctor) {
128: return Redirect::back();
129: }
130: }
131: $appointment = Appointment::with('doctor','patient')->find($appointmentId);
132: $patients = $this->prescriptionRepository->getPatients();
133: $doctors = $this->prescriptionRepository->getDoctors();
134: $data['medicines'] = Medicine::pluck('name', 'id')->toArray();
135: $medicines = $data;
136: $data = $this->medicineRepository->getSyncList();
137: $medicineList = $this->medicineRepository->getMedicineList();
138: $mealList = $this->medicineRepository->getMealList();
139: $doseDuration = $this->medicineRepository->getDoseDurationList();
140: $doseInverval = $this->medicineRepository->getDoseInterValList();
141: return view('prescriptions.edit', compact('patients','appointment', 'appointmentId',
142: 'prescription', 'doctors', 'medicines', 'medicineList', 'mealList', 'doseDuration',
143: 'doseInverval'))->with($data);
144: }
145: /**
146: * @return RedirectResponse|Redirector
147: */
148: public function update(Prescription $prescription, UpdatePrescriptionRequest
$request):
149: RedirectResponse
150: {
151: $prescription = $this->prescriptionRepository->find($prescription->id);
152: $input = $request->all();
153: $input['status'] = isset($input['status']) ? 1 : 0;
154: $prescription->load('getMedicine');
155: $arr = collect($input['medicine']);
156: $duplicateIds = $arr->duplicates();
157: foreach ($input['medicine'] as $key => $value) {
158: $medicine = Medicine::find($input['medicine'][$key]);
159: if (! empty($duplicateIds)) {
160: foreach ($duplicateIds as $key => $value) {
161: $medicine = Medicine::find($duplicateIds[$key]);
162: Flash::error(__('messages.prescription.not_add_duplicate_medicines'));
163: return Redirect::back();
164: }
165: }
166: }
167: $prescriptionMedicineArray = [];
168: $inputdoseAndMedicine = [];
169: foreach ($prescription->getMedicine as $prescriptionMedicine) {
170: $prescriptionMedicineArray[$prescriptionMedicine->medicine] =
171: $prescriptionMedicine->dosage;
172: }
173: foreach ($request->medicine as $key => $value) {
174: $inputdoseAndMedicine[$value] = $request->dosage[$key];
175: }
176: if (empty($prescription)) {
177: Flash::error(__('messages.flash.prescription_not_found'));
178: return Redirect::back();
179: }
180: foreach ($input['medicine'] as $key => $value) {
181: // dump($prescriptionMedicineArray);
182: // dump($inputdoseAndMedicine);
183: $result = array_intersect($prescriptionMedicineArray, $inputdoseAndMedicine);
184: // dump($result);
185: // dd(!array_key_exists($input['medicine'][$key], $result));
186: $medicine = Medicine::find($input['medicine'][$key]);
187: $qty = $input['day'][$key] * $input['dose_interval'][$key];
188: if (! array_key_exists($input['medicine'][$key], $result) &&
$medicine->available_quantity
189: < $qty) {
190: $available = $medicine->available_quantity == null ? 0 :
$medicine->available_quantity;
191: // Flash::error('The available quantity of '.$medicine->name.' is '.$available.'.');
192:
193: Flash::error(__('messages.prescription.available_quantity_of').$medicine->name.__('m
essages.prescription.is').$available.'.');
194: return Redirect::back();
195: }
196: }
197: $showRoute = isRole('doctor') ? 'doctors.appointment.detail' : (isRole('patient') ?
198: 'patients.appointment.detail' : 'appointments.show');
199: $this->prescriptionRepository->prescriptionUpdate($prescription, $request->all());
200: Flash::success(__('messages.prescription.prescription_updated'));
201: return redirect(route($showRoute, $input['appointment_id']));
202: }
203: /**
204: * @return JsonResponse|RedirectResponse|Redirector
205: *
206: * @throws Exception
207: */
208: public function destroy(Prescription $prescription)
209: {
210: if (! canAccessRecord(Prescription::class, $prescription->id)) {
211: return $this->sendError(__('messages.flash.prescription_not_found'));
212: }
213: if (getLogInUser()->hasRole('Doctor')) {
214: $patientPrescriptionHasDoctor =
215: Prescription::whereId($prescription->id)->whereDoctorId(getLogInUser()->owner_id)->e
xists();
216: if (! $patientPrescriptionHasDoctor) {
217: return $this->sendError(__('messages.flash.prescription_not_found'));
218: }
219: }
220: $prescription = $this->prescriptionRepository->find($prescription->id);
221: if (empty($prescription)) {
222: Flash::error(__('messages.flash.prescription_not_found'));
223: return Redirect::back();
224: }
225: $prescription->delete();
226: return $this->sendSuccess(__('messages.flash.prescription_deleted'));
227: }
228: public function activeDeactiveStatus(int $id): JsonResponse
229: {
230: $prescription = Prescription::findOrFail($id);
231: $status = ! $prescription->status;
232: $prescription->update(['status' => $status]);
233: return $this->sendSuccess(__('messages.flash.status_update'));
234: }
235: public function showModal($id): JsonResponse
236: {
237: if (getLogInUser()->hasRole('Doctor')) {
238: $patientPrescriptionHasDoctor =
239: Prescription::whereId($id)->whereDoctorId(getLogInUser()->owner_id)->exists();
240: if (! $patientPrescriptionHasDoctor) {
241: return $this->sendError(__('messages.flash.prescription_not_found'));
242: }
243: }
244: $prescription = $this->prescriptionRepository->find($id);
245: $prescription->load(['patient.patientUser', 'doctor.doctorUser']);
246: if (empty($prescription)) {
247: return $this->sendError(__('messages.flash.prescription_not_found'));
248: }
249: return $this->sendResponse($prescription,
__('messages.flash.prescription_retrieved'));
250: }
251: public function prescreptionMedicineStore(CreateMedicineRequest $request):
JsonResponse
252: {
253: $input = $request->all();
254: $this->medicineRepository->create($input);
255: return $this->sendSuccess(__('messages.medicine.medicine').'
256: '.__('messages.medicine.saved_successfully'));
257: }
258: /**
259: * @return
260: \Illuminate\Contracts\Foundation\Application|Factory|\Illuminate\Contracts\View\View
261: */
262: public function prescriptionMedicineShowFunction($id)
263: {
264: if (getLogInUser()->hasRole('Doctor')) {
265: $patientPrescriptionHasDoctor =
266: Prescription::whereId($id)->whereDoctorId(getLogInUser()->owner_id)->exists();
267: if (! $patientPrescriptionHasDoctor) {
268: return Redirect::back();
269: }
270: }
271: $data = $this->prescriptionRepository->getSettingList();
272: $prescription = $this->prescriptionRepository->getData($id);
273: $medicines = $this->prescriptionRepository->getMedicineData($id);
274: return view('prescriptions.show_with_medicine', compact('prescription', 'medicines',
275: 'data'));
276: }
277: public function convertToPDF($id): \Illuminate\Http\Response
278: {
279: $data = $this->prescriptionRepository->getSettingList();
280: $prescription = $this->prescriptionRepository->getData($id);
281: $medicines = $this->prescriptionRepository->getMedicineData($id);
282: $pdf = PDF::loadView('prescriptions.prescription_pdf', compact('prescription',
283: 'medicines', 'data'));
284: return
285: $pdf->stream($prescription['prescription']->patient->user->full_name.'-'.$prescripti
on['prescription']->id);
286: }
287: }
[Http > Controllers > PurchaseMedicineController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Exports\PurchaseMedicineExport;
4: use App\Http\Requests\CreatePurchaseMedicineRequest;
5: use App\Models\Medicine;
6: use App\Models\PurchaseMedicine;
7: use App\Repositories\MedicineRepository;
8: use App\Repositories\PurchaseMedicineRepository;
9: use Illuminate\Http\JsonResponse;
10: use Illuminate\Http\RedirectResponse;
11: use Illuminate\View\View;
12: use Laracasts\Flash\Flash;
13: use Maatwebsite\Excel\Facades\Excel;
14: class PurchaseMedicineController extends AppBaseController
15: {
16: /** @var PurchaseMedicineRepository */
17: /** @var MedicineRepository */
18: private $prchaseMedicineRepository;
19: private $medicineRepository;
20: public function __construct(PurchaseMedicineRepository $purchaseMedicineRepo,
21: MedicineRepository $medicineRepository)
22: {
23: $this->prchaseMedicineRepository = $purchaseMedicineRepo;
24: $this->medicineRepository = $medicineRepository;
25: }
26: public function index(): View
27: {
28: return view('purchase-medicines.index');
29: }
30: public function create(): View
31: {
32: $data = $this->medicineRepository->getSyncList();
33: $medicines = $this->prchaseMedicineRepository->getMedicine();
34: $medicineList = $this->prchaseMedicineRepository->getMedicineList();
35: $categories = $this->prchaseMedicineRepository->getCategory();
36: $categoriesList = $this->prchaseMedicineRepository->getCategoryList();
37: return view('purchase-medicines.create', compact('medicines', 'medicineList',
38: 'categories', 'categoriesList'))->with($data);
39: }
40: public function store(CreatePurchaseMedicineRequest $request): RedirectResponse
41: {
42: $input = $request->all();
43: $this->prchaseMedicineRepository->store($input);
44: flash::success(__('messages.purchase_medicine.purchased_medicine_success'));
45: return redirect(route('medicine-purchase.index'));
46: }
47: /**
48: * @param PurchaseMedicine $purchaseMedicine
49: */
50: public function show(PurchaseMedicine $medicinePurchase): View
51: {
52: $medicinePurchase->load(['purchasedMedcines.medicines']);
53: return view('purchase-medicines.show', compact('medicinePurchase'));
54: }
55: public function getMedicine(Medicine $medicine): JsonResponse
56: {
57: return $this->sendResponse($medicine, 'retrieved');
58: }
59: public function purchaseMedicineExport()
60: {
61: $response = Excel::download(new PurchaseMedicineExport,
62: 'purchase-medicine-'.time().'.xlsx');
63: ob_end_clean();
64: return $response;
65: }
66: /**
67: * [Description for usedMedicine]
68: *
69: * @return [type]
70: */
71: public function usedMedicine(): View
72: {
73: return view('used-medicine.index');
74: }
75: public function destroy(PurchaseMedicine $medicinePurchase)
76: {
77: $medicinePurchase->delete();
78: return $this->sendSuccess(__('messages.flash.medicine_deleted'));
79: }
80: }
[Http > Controllers > RazorpayController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Models\Appointment;
4: use App\Models\Notification;
5: use App\Models\Patient;
6: use App\Models\Transaction;
7: use Auth;
8: use Exception;
9: use Flash;
10: use Illuminate\Http\Request;
11: use Illuminate\Support\Facades\Log;
12: use Razorpay\Api\Api;
13: class RazorpayController extends AppBaseController
14: {
15: public function onBoard(Request $request): \Illuminate\Http\JsonResponse
16: {
17: $appointmentID = $request->appointmentId;
18: $appointment = Appointment::whereId($appointmentID)->first();
19: $patient = Patient::with('user')->whereId($appointment->patient_id)->first();
20: $amount = $appointment->payable_amount;
21: $api = new Api(config('payments.razorpay.key'), config('payments.razorpay.secret'));
22: $orderData = [
23: 'receipt' => '1',
24: 'amount' => $amount * 100, // 100 = 1 rupees
25: 'currency' => getCurrencyCode(),
26: 'notes' => [
27: 'email' => $patient->user->email,
28: 'name' => $patient->user->full_name,
29: 'appointmentID' => $appointmentID,
30: ],
31: ];
32: $razorpayOrder = $api->order->create($orderData);
33: $data['id'] = $razorpayOrder->id;
34: $data['amount'] = $amount;
35: $data['name'] = $patient->user->full_name;
36: $data['email'] = $patient->user->email;
37: $data['contact'] = $patient->user->contact;
38: return $this->sendResponse($data, __('messages.flash.order_create'));
39: }
40: public function paymentSuccess(Request $request)
41: {
42: $input = $request->all();
43: Log::info('RazorPay Payment Successfully');
44: Log::info($input);
45: $api = new Api(config('payments.razorpay.key'), config('payments.razorpay.secret'));
46: if (count($input) && ! empty($input['razorpay_payment_id'])) {
47: try {
48: $payment = $api->payment->fetch($input['razorpay_payment_id']);
49: $generatedSignature = hash_hmac('sha256',
50: $payment['order_id'].'|'.$input['razorpay_payment_id'],
51: config('payments.razorpay.secret'));
52: if ($generatedSignature != $input['razorpay_signature']) {
53: return redirect()->back();
54: }
55: // Create Transaction Here
56: $appointmentID = $payment['notes']['appointmentID'];
57: $appointment = Appointment::whereId($appointmentID)->first();
58: $patient = Patient::with('user')->whereId($appointment->patient_id)->first();
59: $transaction = [
60: 'user_id' => $patient->user->id,
61: 'transaction_id' => $payment->id,
62: 'appointment_id' => $appointment['appointment_unique_id'],
63: 'amount' => intval($appointment['payable_amount']),
64: 'type' => Appointment::RAZORPAY,
65: 'meta' => $payment->toArray(),
66: ];
67: Transaction::create($transaction);
68: $appointment->update([
69: 'payment_method' => Appointment::RAZORPAY,
70: 'payment_type' => Appointment::PAID,
71: ]);
72: Flash::success(__('messages.flash.appointment_created_payment_complete'));
73: Notification::create([
74: 'title' => Notification::APPOINTMENT_PAYMENT_DONE_PATIENT_MSG,
75: 'type' => Notification::PAYMENT_DONE,
76: 'user_id' => $patient->user->id,
77: ]);
78: if (! getLogInUser()) {
79: return redirect(route('medicalAppointment'));
80: }
81: if (getLogInUser()->hasRole('patient')) {
82: return redirect(route('patients.patient-appointments-index'));
83: }
84: return redirect(route('appointments.index'));
85: } catch (Exception $e) {
86: return false;
87: }
88: }
89: return redirect()->back();
90: }
91: public function paymentFailed(Request $request): \Illuminate\Http\JsonResponse
92: {
93: $data = $request->get('data');
94: Log::info('payment failed');
95: Log::info($data);
96: $user = Auth::user();
97: $error = $data['error'];
98: if (isset($error['metadata']['order_id'])) {
99: // failed transactions here
100: }
101: Flash::error(__('messages.flash.appointment_created_payment_not_complete'));
102: if (! getLogInUser()) {
103: return redirect(route('medicalAppointment'));
104: }
105: if (getLogInUser()->hasRole('patient')) {
106: return redirect(route('patients.patient-appointments-index'));
107: }
108: return redirect(route('appointments.index'));
109: }
110: public function paymentSuccessWebHook(Request $request): bool
111: {
112: $input = $request->all();
113: Log::info('webHook Razorpay');
114: Log::info($input);
115: if (isset($input['event']) && $input['event'] == 'payment.captured' &&
116: isset($input['payload']['payment']['entity'])) {
117: $payment = $input['payload']['payment']['entity'];
118: // success response
119: }
120: return false;
121: }
122: }
[Http > Controllers > ReviewController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\CreateReviewRequest;
4: use App\Http\Requests\UpdateReviewRequest;
5: use App\Models\Appointment;
6: use App\Models\Doctor;
7: use App\Models\Notification;
8: use App\Models\Patient;
9: use App\Models\Review;
10: use Illuminate\Contracts\Foundation\Application;
11: use Illuminate\Contracts\View\Factory;
12: use Illuminate\Contracts\View\View;
13: class ReviewController extends AppBaseController
14: {
15: /**
16: * @return Application|Factory|View
17: */
18: public function index(): \Illuminate\View\View
19: {
20: $patient = Patient::whereUserId(getLogInUserId())->first();
21: $doctorIds =
22: Appointment::wherePatientId($patient['id'])->whereStatus(Appointment::CHECK_OUT)->plu
ck('doctor_id')->toArray();
23: $doctors = Doctor::with('user', 'specializations', 'reviews')
24: ->whereIn('id', $doctorIds)
25: ->get();
26: return view('reviews.index', compact('doctors'));
27: }
28: /**
29: * @return mixed
30: */
31: public function store(CreateReviewRequest $request)
32: {
33: $canReview =
34: Appointment::wherePatientId(getLogInUser()->patient->id)->whereDoctorId($request->doc
tor_id);
35: if (! $canReview->exists()) {
36: return $this->sendError(__('messages.common.not_allow__assess_record'));
37: }
38: $input = $request->all();
39: $patient = Patient::whereUserId(getLogInUserId())->first();
40: $input['patient_id'] = $patient['id'];
41: Review::create($input);
42: Notification::create([
43: 'title' => getLogInUser()->full_name.' just added '.$input['rating'].' star review
for
44: you.',
45: 'type' => Notification::REVIEW,
46: 'user_id' => Doctor::whereId($input['doctor_id'])->first()->user_id,
47: ]);
48: return $this->sendSuccess(__('messages.flash.review_add'));
49: }
50: /**
51: * @return mixed
52: */
53: public function edit(Review $review)
54: {
55: $canEditReview =
56: Review::whereId($review->id)->wherePatientId(getLogInUser()->patient->id);
57: if (! $canEditReview->exists()) {
58: return $this->sendError(__('messages.common.not_allow__assess_record'));
59: }
60: return $this->sendResponse($review, __('messages.flash.review_retrieved'));
61: }
62: /**
63: * @return mixed
64: */
65: public function update(UpdateReviewRequest $request, Review $review)
66: {
67: $data = $request->all();
68: $review->update($data);
69: return $this->sendSuccess(__('messages.flash.review_edit'));
70: }
71: }
[Http > Controllers > RoleController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\CreateRoleRequest;
4: use App\Http\Requests\UpdateRoleRequest;
5: use App\Models\Permission;
6: use App\Models\Role;
7: use App\Repositories\RoleRepository;
8: use Illuminate\Contracts\Foundation\Application;
9: use Illuminate\Contracts\View\Factory;
10: use Illuminate\Contracts\View\View;
11: use Illuminate\Http\JsonResponse;
12: use Illuminate\Http\RedirectResponse;
13: use Illuminate\Routing\Redirector;
14: use Illuminate\Support\Facades\DB;
15: class RoleController extends AppBaseController
16: {
17: /** @var RoleRepository */
18: private $roleRepository;
19: public function __construct(RoleRepository $roleRepo)
20: {
21: $this->roleRepository = $roleRepo;
22: }
23: /**
24: * @return Application|Factory|View
25: */
26: public function index(): \Illuminate\View\View
27: {
28: $permissions = Permission::toBase()->get();
29: return view('roles.index', compact('permissions'));
30: }
31: /**
32: * @return Application|Factory|View
33: */
34: public function create(): \Illuminate\View\View
35: {
36: $permissions = $this->roleRepository->getPermissions();
37: return view('roles.create', compact('permissions'));
38: }
39: /**
40: * Store a newly created Role in storage.
41: *
42: * @return Application|RedirectResponse|Redirector
43: */
44: public function store(CreateRoleRequest $request): RedirectResponse
45: {
46: $input = $request->all();
47: $this->roleRepository->store($input);
48: \Flash::success(__('messages.flash.role_create'));
49: return redirect(route('roles.index'));
50: }
51: /**
52: * Show the form for editing the specified Role.
53: *
54: * @return Application|Factory|View
55: */
56: public function edit(Role $role): \Illuminate\View\View
57: {
58: $permissions = $this->roleRepository->getPermissions();
59: $selectedPermissions = $role->getAllPermissions()->keyBy('id');
60: return view('roles.edit', compact('role', 'permissions', 'selectedPermissions'));
61: }
62: /**
63: * Update the specified Role in storage.
64: *
65: * @return Application|Redirector|RedirectResponse
66: */
67: public function update(UpdateRoleRequest $request, Role $role): RedirectResponse
68: {
69: $this->roleRepository->update($request->all(), $role->id);
70: \Flash::success(__('messages.flash.role_update'));
71: return redirect(route('roles.index'));
72: }
73: /**
74: * Remove the specified Role from storage.
75: */
76: public function destroy(Role $role): JsonResponse
77: {
78: if ($role->is_default == 1) {
79: return $this->sendError(__('messages.flash.default_role_not_delete'));
80: }
81: $checkRecord = DB::table('model_has_roles')->where('role_id', '=',
$role->id)->exists();
82: if ($checkRecord) {
83: return $this->sendError(__('messages.flash.user_role_not_delete'));
84: }
85: $role->delete();
86: return $this->sendSuccess(__('messages.flash.role_delete'));
87: }
88: }
[Http > Controllers > ServiceCategoryController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\CreateServiceCategoryRequest;
4: use App\Http\Requests\UpdateServiceCategoryRequest;
5: use App\Models\Service;
6: use App\Models\ServiceCategory;
7: use App\Repositories\ServiceCategoryRepository;
8: use Illuminate\Contracts\Foundation\Application;
9: use Illuminate\Contracts\View\Factory;
10: use Illuminate\Contracts\View\View;
11: use Illuminate\Http\JsonResponse;
12: class ServiceCategoryController extends AppBaseController
13: {
14: /** @var ServiceCategoryRepository */
15: private $serviceCategoryRepository;
16: public function __construct(ServiceCategoryRepository $serviceCategoryRepo)
17: {
18: $this->serviceCategoryRepository = $serviceCategoryRepo;
19: }
20: /**
21: * Display a listing of the ServiceCategory.
22: *
23: * @return Application|Factory|View
24: */
25: public function index(): \Illuminate\View\View
26: {
27: return view('service_categories.index');
28: }
29: /**
30: * Store a newly created ServiceCategory in storage.
31: */
32: public function store(CreateServiceCategoryRequest $request): JsonResponse
33: {
34: $input = $request->all();
35: $serviceCategory = $this->serviceCategoryRepository->create($input);
36: return $this->sendResponse($serviceCategory,
__('messages.flash.service_cat_create'));
37: }
38: /**
39: * Show the form for editing the specified ServiceCategory.
40: */
41: public function edit(ServiceCategory $serviceCategory): JsonResponse
42: {
43: return $this->sendResponse($serviceCategory, __('messages.flash.cat_retrieve'));
44: }
45: /**
46: * Update the specified ServiceCategory in storage.
47: */
48: public function update(UpdateServiceCategoryRequest $request, ServiceCategory
49: $serviceCategory): JsonResponse
50: {
51: $input = $request->all();
52: $this->serviceCategoryRepository->update($input, $serviceCategory->id);
53: return $this->sendSuccess(__('messages.flash.service_cat_update'));
54: }
55: /**
56: * Remove the specified ServiceCategory from storage.
57: */
58: public function destroy(ServiceCategory $serviceCategory): JsonResponse
59: {
60: $checkRecord = Service::whereCategoryId($serviceCategory->id)->exists();
61: if ($checkRecord) {
62: return $this->sendError(__('messages.flash.service_cat_use'));
63: }
64: $serviceCategory->delete();
65: return $this->sendSuccess(__('messages.flash.service_cat_delete'));
66: }
67: }
[Http > Controllers > ServiceController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\CreateServicesRequest;
4: use App\Http\Requests\UpdateServicesRequest;
5: use App\Models\Appointment;
6: use App\Models\Service;
7: use App\Repositories\ServicesRepository;
8: use Illuminate\Contracts\Foundation\Application;
9: use Illuminate\Contracts\View\Factory;
10: use Illuminate\Contracts\View\View;
11: use Illuminate\Http\JsonResponse;
12: use Illuminate\Http\RedirectResponse;
13: use Illuminate\Http\Request;
14: use Illuminate\Routing\Redirector;
15: use Laracasts\Flash\Flash;
16: class ServiceController extends AppBaseController
17: {
18: /** @var ServicesRepository */
19: private $servicesRepository;
20: public function __construct(ServicesRepository $servicesRepo)
21: {
22: $this->servicesRepository = $servicesRepo;
23: }
24: /**
25: * @return Application|Factory|View
26: */
27: public function index(): \Illuminate\View\View
28: {
29: $status = Service::STATUS;
30: return view('services.index', compact('status'));
31: }
32: /**
33: * Show the form for creating a new Services.
34: *
35: * @return Application|Factory|View
36: */
37: public function create(): \Illuminate\View\View
38: {
39: $data = $this->servicesRepository->prepareData();
40: return view('services.create', compact('data'));
41: }
42: /**
43: * Store a newly created Services in storage.
44: *
45: * @return Application|RedirectResponse|Redirector
46: */
47: public function store(CreateServicesRequest $request): RedirectResponse
48: {
49: $input = $request->all();
50: $this->servicesRepository->store($input);
51: Flash::success(__('messages.flash.service_create'));
52: return redirect(route('services.index'));
53: }
54: /**
55: * Show the form for editing the specified Services.
56: *
57: * @return Application|Factory|View
58: */
59: public function edit(Service $service): \Illuminate\View\View
60: {
61: $data = $this->servicesRepository->prepareData();
62: $selectedDoctor = $service->serviceDoctors()->pluck('doctor_id')->toArray();
63: return view('services.edit', compact('service', 'data', 'selectedDoctor'));
64: }
65: /**
66: * Update the specified Services in storage.
67: *
68: * @return Application|Redirector|RedirectResponse
69: */
70: public function update(UpdateServicesRequest $request, Service $service):
RedirectResponse
71: {
72: $this->servicesRepository->update($request->all(), $service);
73: Flash::success(__('messages.flash.service_update'));
74: return redirect(route('services.index'));
75: }
76: /**
77: * Remove the specified Services from storage.
78: */
79: public function destroy(Service $service): JsonResponse
80: {
81: $checkRecord = Appointment::whereServiceId($service->id)->exists();
82: if ($checkRecord) {
83: return $this->sendError(__('messages.flash.service_use'));
84: }
85: $service->delete();
86: return $this->sendSuccess(__('messages.flash.service_delete'));
87: }
88: public function getService(Request $request)
89: {
90: $doctor_id = $request->appointmentDoctorId;
91: $service = Service::with('serviceDoctors')->whereHas('serviceDoctors', function ($q)
use
92: ($doctor_id) {
93: $q->where('doctor_id', $doctor_id)->whereStatus(Service::ACTIVE);
94: })->get();
95: return $this->sendResponse($service, __('messages.flash.retrieve'));
96: }
97: public function getCharge(Request $request): JsonResponse
98: {
99: $chargeId = $request->chargeId;
100: $charge = Service::find($chargeId);
101: return $this->sendResponse($charge, __('messages.flash.retrieve'));
102: }
103: /**
104: * @return mixed
105: */
106: public function changeServiceStatus(Request $request)
107: {
108: $status = Service::findOrFail($request->id);
109: $status->update(['status' => ! $status->status]);
110: return $this->sendResponse($status, __('messages.flash.status_update'));
111: }
112: }
[Http > Controllers > SettingController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\UpdateSettingRequest;
4: use App\Models\Appointment;
5: use App\Models\City;
6: use App\Models\Country;
7: use App\Models\Currency;
8: use App\Models\PaymentGateway;
9: use App\Models\Setting;
10: use App\Models\Specialization;
11: use App\Models\State;
12: use App\Repositories\SettingRepository;
13: use Illuminate\Contracts\Foundation\Application;
14: use Illuminate\Contracts\View\Factory;
15: use Illuminate\Contracts\View\View;
16: use Illuminate\Http\RedirectResponse;
17: use Illuminate\Http\Request;
18: use Illuminate\Support\Facades\Auth;
19: use Illuminate\Support\Facades\Redirect;
20: use Laracasts\Flash\Flash;
21: use App\Models\User;
22: use Illuminate\Support\Facades\Session;
23: class SettingController extends AppBaseController
24: {
25: /**
26: * @var SettingRepository
27: */
28: private $settingRepository;
29: /**
30: * SettingController constructor.
31: */
32: public function __construct(SettingRepository $SettingRepository)
33: {
34: $this->settingRepository = $SettingRepository;
35: }
36: /**
37: * @return Application|Factory|View
38: */
39: public function index(Request $request): \Illuminate\View\View
40: {
41: $setting = Setting::pluck('value', 'key')->toArray();
42: $sectionName = ($request->get('section') === null) ? 'general' :
$request->get('section');
43: $states = $cities = [];
44: if (isset($setting['country_id'])) {
45: $states = getStates($setting['country_id']);
46: }
47: if (isset($states)) {
48: $cities = getCities($states);
49: }
50: $countries = Country::toBase()->pluck('name', 'id');
51: $specialities = Specialization::orderBy('name', 'asc')->pluck('name', 'id');
52: $currencies = Currency::toBase()->pluck('currency_name', 'id');
53: $paymentGateways = Appointment::PAYMENT_METHOD;
54: $languages = User::LANGUAGES;
55: $courentlanguage = Setting::where('key','language')->get()->toArray()[0]['value'];
56: $selectedPaymentGateways = PaymentGateway::pluck('payment_gateway')->toArray();
57: return view("setting.$sectionName",
58: compact('sectionName', 'setting', 'countries', 'specialities', 'states', 'cities',
59: 'currencies','languages','courentlanguage', 'paymentGateways',
60: 'selectedPaymentGateways'));
61: }
62: public function update(UpdateSettingRequest $request): RedirectResponse
63: {
64: $language = $request->language;
65: if(!empty($language)){
66: Setting::where('key','language')->update([
67: 'value' => $language,
68: ]);
69: $appointment = user::whereNot('type',User::ADMIN)->get();
70: foreach ($appointment as $appointment) {
71: if($language == null)
72: {
73: $appointment->update([
74: 'language' => 'en',
75: ]);
76: }else{
77: $appointment->update([
78: 'language' => $language,
79: ]);
80: }
81: session()->forget('languageName');
82: }
83: }
84: $paymentGateways = $request->payment_gateway;
85: if (! empty($paymentGateways)) {
86: PaymentGateway::query()->delete();
87: }
88: if (isset($paymentGateways)) {
89: foreach ($paymentGateways as $paymentGateway) {
90: PaymentGateway::updateOrCreate(['payment_gateway_id' => $paymentGateway],
91: [
92: 'payment_gateway' => Appointment::PAYMENT_METHOD[$paymentGateway],
93: ]);
94: }
95: }
96: $id = Auth::id();
97: $this->settingRepository->update($request->all(), $id);
98: Flash::success(__('messages.flash.setting_update'));
99: return Redirect::back();
100: }
101: /**
102: * @return mixed
103: */
104: public function getStates(Request $request)
105: {
106: $countryId = $request->get('settingCountryId');
107: $data['state_id'] = getSettingValue('state_id');
108: $data['states'] = State::where('country_id', $countryId)->toBase()->pluck('name',
109: 'id')->toArray();
110: return $this->sendResponse($data, __('messages.flash.states_retrieve'));
111: }
112: /**
113: * @return mixed
114: */
115: public function getCities(Request $request)
116: {
117: $state_id = $request->get('stateId');
118: $data['city_id'] = getSettingValue('city_id');
119: $data['cities'] = City::where('state_id', $state_id)->toBase()->pluck('name',
120: 'id')->toArray();
121: return $this->sendResponse($data, __('messages.flash.cities_retrieve'));
122: }
123: }
[Http > Controllers > SmartPatientCardsController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Models\Setting;
4: use Illuminate\Http\Request;
5: use App\Repositories\SmartPatientCardsRepository;
6: use App\Models\SmartPatientCards;
7: use Flash;
8: use SimpleSoftwareIO\QrCode\Facades\QrCode;
9: use App\Http\Requests\CreateSmartCardTemplateRequest;
10: class SmartPatientCardsController extends AppBaseController
11: {
12: private $SmartPatientCardsRepository;
13: public function __construct(SmartPatientCardsRepository $staffRepo)
14: {
15: $this->SmartPatientCardsRepository = $staffRepo;
16: }
17: /**
18: * Display a listing of the resource.
19: */
20: public function index()
21: {
22: return view('smart_patient_cards.index');
23: }
24: /**
25: * Show the form for creating a new resource.
26: */
27: public function create()
28: {
29: $qr = QrCode::generate('Make me into a QrCode!');
30: $logo = Setting::where('key','logo')->pluck('value');
31: $clinic_name = Setting::where('key','clinic_name')->pluck('value')->first();
32: $address_one = Setting::where('key','address_one')->pluck('value')->first();
33: return
34: view('smart_patient_cards/create',compact('logo','qr','clinic_name','address_one'));
35: }
36: /**
37: * Store a newly created resource in storage.
38: */
39: public function store(CreateSmartCardTemplateRequest $request)
40: {
41: $input = $request->all();
42: $this->SmartPatientCardsRepository->store($input);
43: Flash::success(__('messages.smart_patient_card.template_created'));
44: if (isRole('doctor')) {
45: return redirect(route('doctors.smart-patient-cards.index'));
46: }
47: if (isRole('clinic_admin')) {
48: return redirect(route('smart-patient-cards.index'));
49: }
50: }
51: /**
52: * Display the specified resource.
53: */
54: public function show(string $id)
55: {
56: //
57: }
58: /**
59: * Show the form for editing the specified resource.
60: */
61: public function edit(string $id)
62: {
63: $smart_patient_cards = SmartPatientCards::where('id',$id)->first();
64: $logo = Setting::where('key','logo')->pluck('value');
65: $clinic_name = Setting::where('key','clinic_name')->pluck('value')->first();
66: $address_one = Setting::where('key','address_one')->pluck('value')->first();
67: return
68: view('smart_patient_cards.edit',compact('smart_patient_cards','logo','clinic_name','a
ddress_one'));
69: }
70: /**
71: * Update the specified resource in storage.
72: */
73: public function update(Request $request, string $id)
74: {
75: $this->SmartPatientCardsRepository->update($request->all(), $id);
76: Flash::success(__('messages.smart_patient_card.template_update'));
77: if (isRole('doctor')) {
78: return redirect(route('doctors.smart-patient-cards.index'));
79: }
80: if (isRole('clinic_admin')) {
81: return redirect(route('smart-patient-cards.index'));
82: }
83: }
84: /**
85: * Remove the specified resource from storage.
86: */
87: public function destroy(string $id)
88: {
89: SmartPatientCards::where('id',$id)->delete();
90: return $this->sendSuccess(__('messages.smart_patient_card.template_deleted'));
91: }
92: public function changeCardStatus(Request $request ,$id) {
93: $status = SmartPatientCards::findOrFail($id);
94: $status->update([$request->changefield => $request->status]);
95: return $this->sendResponse($status,
__('messages.smart_patient_card.template_update'));
96: }
97: }
[Http > Controllers > SpecializationController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\CreateSpecializationRequest;
4: use App\Http\Requests\UpdateSpecializationRequest;
5: use App\Models\Specialization;
6: use App\Repositories\SpecializationRepository;
7: use Illuminate\Contracts\Foundation\Application;
8: use Illuminate\Contracts\View\Factory;
9: use Illuminate\Contracts\View\View;
10: use Illuminate\Http\JsonResponse;
11: class SpecializationController extends AppBaseController
12: {
13: /** @var SpecializationRepository */
14: private $specializationRepository;
15: public function __construct(SpecializationRepository $specializationRepo)
16: {
17: $this->specializationRepository = $specializationRepo;
18: }
19: /**
20: * Display a listing of the Specialization.
21: *
22: * @return Application|Factory|View
23: */
24: public function index(): \Illuminate\View\View
25: {
26: return view('specializations.index');
27: }
28: /**
29: * Store a newly created Specialization in storage.
30: */
31: public function store(CreateSpecializationRequest $request): JsonResponse
32: {
33: $input = $request->all();
34: $this->specializationRepository->create($input);
35: return $this->sendSuccess(__('messages.flash.specialization_create'));
36: }
37: /**
38: * Show the form for editing the specified Specialization.
39: */
40: public function edit(Specialization $specialization): JsonResponse
41: {
42: return $this->sendResponse($specialization,
43: __('messages.specialization.retrieved_successfully'));
44: }
45: /**
46: * Update the specified Specialization in storage.
47: */
48: public function update(UpdateSpecializationRequest $request, Specialization
49: $specialization): JsonResponse
50: {
51: $this->specializationRepository->update($request->all(), $specialization->id);
52: return $this->sendSuccess(__('messages.flash.specialization_update'));
53: }
54: /**
55: * Remove the specified Specialization from storage.
56: */
57: public function destroy(Specialization $specialization): JsonResponse
58: {
59: if ($specialization->doctors()->count()) {
60: return $this->sendError(__('messages.flash.specialization_used_some_where'));
61: }
62: $specialization->delete();
63: return $this->sendSuccess(__('messages.flash.specialization_delete'));
64: }
65: }
[Http > Controllers > StaffController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\CreateStaffRequest;
4: use App\Http\Requests\UpdateStaffRequest;
5: use App\Models\User;
6: use App\Repositories\StaffRepository;
7: use Flash;
8: use Illuminate\Contracts\Foundation\Application;
9: use Illuminate\Contracts\View\Factory;
10: use Illuminate\Contracts\View\View;
11: use Illuminate\Http\JsonResponse;
12: use Illuminate\Http\RedirectResponse;
13: use Illuminate\Routing\Redirector;
14: class StaffController extends AppBaseController
15: {
16: /** @var StaffRepository */
17: private $staffRepository;
18: public function __construct(StaffRepository $staffRepo)
19: {
20: $this->staffRepository = $staffRepo;
21: }
22: /**
23: * Display a listing of the Staff.
24: *
25: * @return Application|Factory|View
26: */
27: public function index(): \Illuminate\View\View
28: {
29: return view('staffs.index');
30: }
31: /**
32: * Show the form for creating a new Staff.
33: *
34: * @return Application|Factory|View
35: */
36: public function create(): \Illuminate\View\View
37: {
38: $roles = $this->staffRepository->getRole();
39: return view('staffs.create', compact('roles'));
40: }
41: /**
42: * Store a newly created Staff in storage.
43: *
44: * @return Application|Redirector|RedirectResponse
45: */
46: public function store(CreateStaffRequest $request): RedirectResponse
47: {
48: $input = $request->all();
49: $this->staffRepository->store($input);
50: Flash::success(__('messages.flash.staff_create'));
51: return redirect(route('staffs.index'));
52: }
53: /**
54: * @return Application|Factory|View
55: */
56: public function show(User $staff): \Illuminate\View\View
57: {
58: $staff = User::whereType(User::STAFF)->findOrFail($staff['id']);
59: return view('staffs.show', compact('staff'));
60: }
61: /**
62: * Show the form for editing the specified Staff.
63: *
64: * @return Application|Factory|View
65: */
66: public function edit(User $staff): \Illuminate\View\View
67: {
68: $roles = $this->staffRepository->getRole();
69: return view('staffs.edit', compact('staff', 'roles'));
70: }
71: /**
72: * Update the specified Staff in storage.
73: *
74: * @return Application|RedirectResponse|Redirector
75: */
76: public function update(UpdateStaffRequest $request, User $staff): RedirectResponse
77: {
78: $this->staffRepository->update($request->all(), $staff->id);
79: Flash::success(__('messages.flash.staff_update'));
80: return redirect(route('staffs.index'));
81: }
82: /**
83: * Remove the specified Staff from storage.
84: */
85: public function destroy(User $staff): JsonResponse
86: {
87: $staff->delete();
88: return $this->sendSuccess(__('messages.flash.staff_delete'));
89: }
90: }
[Http > Controllers > StateController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\CreateStateRequest;
4: use App\Http\Requests\UpdateStateRequest;
5: use App\Models\Address;
6: use App\Models\Country;
7: use App\Models\State;
8: use App\Repositories\StateRepository;
9: use Illuminate\Contracts\Foundation\Application;
10: use Illuminate\Contracts\View\Factory;
11: use Illuminate\Contracts\View\View;
12: use Illuminate\Http\JsonResponse;
13: class StateController extends AppBaseController
14: {
15: /** @var StateRepository */
16: private $stateRepository;
17: public function __construct(StateRepository $stateRepo)
18: {
19: $this->stateRepository = $stateRepo;
20: }
21: /**
22: * Display a listing of the State.
23: *
24: * @return Application|Factory|View
25: */
26: public function index(): \Illuminate\View\View
27: {
28: $countries = Country::orderBy('name', 'ASC')->pluck('name', 'id');
29: return view('states.index', compact('countries'));
30: }
31: /**
32: * Store a newly created State in storage.
33: */
34: public function store(CreateStateRequest $request): JsonResponse
35: {
36: $input = $request->all();
37: $state = $this->stateRepository->create($input);
38: return $this->sendSuccess(__('messages.flash.state_create'));
39: }
40: /**
41: * Show the form for editing the specified State.
42: */
43: public function edit(State $state): JsonResponse
44: {
45: return $this->sendResponse($state, __('messages.flash.states_retrieve'));
46: }
47: /**
48: * Update the specified State in storage.
49: */
50: public function update(UpdateStateRequest $request, State $state): JsonResponse
51: {
52: $input = $request->all();
53: $this->stateRepository->update($input, $state->id);
54: return $this->sendSuccess(__('messages.flash.state_delete'));
55: }
56: public function destroy(State $state): JsonResponse
57: {
58: $checkRecord = Address::whereStateId($state->id)->exists();
59: if ($checkRecord) {
60: return $this->sendError(__('messages.flash.state_use'));
61: }
62: $state->delete();
63: return $this->sendSuccess(__('messages.flash.state_delete'));
64: }
65: }
[Http > Controllers > TransactionController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Models\Appointment;
4: use App\Models\Notification;
5: use App\Models\Patient;
6: use App\Models\Transaction;
7: use App\Repositories\TransactionRepository;
8: use Carbon\Carbon;
9: use Illuminate\Contracts\Foundation\Application;
10: use Illuminate\Contracts\View\Factory;
11: use Illuminate\Contracts\View\View;
12: use Illuminate\Http\JsonResponse;
13: use Illuminate\Http\RedirectResponse;
14: use Illuminate\Http\Request;
15: class TransactionController extends AppBaseController
16: {
17: /** @var TransactionRepository */
18: private $transactionRepository;
19: public function __construct(TransactionRepository $transactionRepository)
20: {
21: $this->TransactionRepository = $transactionRepository;
22: }
23: /**
24: * @return Application|Factory|View
25: */
26: public function index(): \Illuminate\View\View
27: {
28: if (getLogInUser()->hasRole('patient')) {
29: return view('transactions.patient_transaction');
30: }
31: if (getLogInUser()->hasRole('doctor')) {
32: return view('transactions.doctors_transaction');
33: }
34: return view('transactions.index');
35: }
36: public function show($id): View|Factory|RedirectResponse|Application
37: {
38: if (getLogInUser()->hasRole('patient')) {
39: $transaction = Transaction::findOrFail($id);
40: if ($transaction->user_id !== getLogInUserId()) {
41: return redirect()->back();
42: }
43: }
44: if (getLogInUser()->hasRole('doctor')) {
45: $transaction = Transaction::with('doctorappointment')->findOrFail($id);
46: if (! $transaction->doctorappointment) {
47: return redirect()->back();
48: }
49: }
50: $transaction = $this->TransactionRepository->show($id);
51: return view('transactions.show', compact('transaction'));
52: }
53: public function changeTransactionStatus(Request $request): JsonResponse
54: {
55: $input = $request->all();
56: $transaction = Transaction::findOrFail($input['id']);
57: $appointment = Appointment::where('appointment_unique_id',
58: $transaction->appointment_id)->first();
59: if (getLogInUser()->hasrole('doctor')) {
60: $doctor = Appointment::where('appointment_unique_id',
61: $transaction->appointment_id)->whereDoctorId(getLogInUser()->doctor->id);
62: if (! $doctor->exists()) {
63: return $this->sendError(__('messages.common.not_allow__assess_record'));
64: }
65: }
66: $appointment->update([
67: 'payment_method' => Appointment::MANUALLY,
68: 'payment_type' => Appointment::PAID,
69: ]);
70: $transaction->update([
71: 'status' => ! $transaction->status,
72: 'accepted_by' => $input['acceptPaymentUserId'],
73: ]);
74: $appointmentNotification =
75: Transaction::with('acceptedPaymentUser')->whereAppointmentId($appointment['appointmen
t_unique_id'])->first();
76: $fullTime = $appointment->from_time.''.$appointment->from_time_type.' -
77: '.$appointment->to_time.''.$appointment->to_time_type.' '.'
78: '.Carbon::parse($appointment->date)->format('jS M, Y');
79: $patient = Patient::whereId($appointment->patient_id)->with('user')->first();
80: Notification::create([
81: 'title' => $appointmentNotification->acceptedPaymentUser->full_name.' changed the
payment
82: status '.Appointment::PAYMENT_TYPE[Appointment::PENDING].' to
83: '.Appointment::PAYMENT_TYPE[$appointment->payment_type].' for appointment
'.$fullTime,
84: 'type' => Notification::PAYMENT_DONE,
85: 'user_id' => $patient->user_id,
86: ]);
87: return $this->sendSuccess(__("messages.flash.status_update"));
88: }
89: }
[Http > Controllers > UserController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\DataTable\UserDataTable;
4: use App\Http\Requests\CreateQualificationRequest;
5: use App\Http\Requests\CreateUserRequest;
6: use App\Http\Requests\UpdateChangePasswordRequest;
7: use App\Http\Requests\UpdateUserProfileRequest;
8: use App\Http\Requests\UpdateUserRequest;
9: use App\Models\Appointment;
10: use App\Models\Doctor;
11: use App\Models\DoctorSession;
12: use App\Models\Specialization;
13: use App\Models\User;
14: use App\Models\Visit;
15: use App\Repositories\UserRepository;
16: use Carbon\Carbon;
17: use DB;
18: use Exception;
19: use Illuminate\Contracts\Foundation\Application;
20: use Illuminate\Contracts\View\Factory;
21: use Illuminate\Contracts\View\View;
22: use Illuminate\Http\JsonResponse;
23: use Illuminate\Http\RedirectResponse;
24: use Illuminate\Http\Request;
25: use Illuminate\Routing\Redirector;
26: use Illuminate\Support\Facades\Auth;
27: use Illuminate\Support\Facades\Hash;
28: use Laracasts\Flash\Flash;
29: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
30: use Yajra\DataTables\DataTables;
31: class UserController extends AppBaseController
32: {
33: /**
34: * @var UserRepository
35: */
36: public $userRepo;
37: /**
38: * UserController constructor.
39: */
40: public function __construct(UserRepository $userRepository)
41: {
42: $this->userRepo = $userRepository;
43: }
44: /**
45: * Display a listing of the resource.
46: *
47: * @return Application|Factory|View
48: *
49: * @throws Exception
50: */
51: public function index(Request $request): \Illuminate\View\View
52: {
53: $years = [];
54: $currentYear = Carbon::now()->format('Y');
55: for ($year = 1960; $year <= $currentYear; $year++) {
56: $years[$year] = $year;
57: }
58: $status = User::STATUS;
59: return view('doctors.index', compact('years', 'status'));
60: }
61: /**
62: * Show the form for creating a new resource.
63: *
64: * @return Application|Factory|View
65: */
66: public function create(): \Illuminate\View\View
67: {
68: $specializations = Specialization::pluck('name', 'id')->toArray();
69: $country = $this->userRepo->getCountries();
70: $bloodGroup = Doctor::BLOOD_GROUP_ARRAY;
71: return view('doctors.create', compact('specializations', 'country', 'bloodGroup'));
72: }
73: /**
74: * Store a newly created resource in storage.
75: *
76: * @return Application|RedirectResponse|Redirector
77: */
78: public function store(CreateUserRequest $request): RedirectResponse
79: {
80: $input = $request->all();
81: $this->userRepo->store($input);
82: Flash::success(__('messages.flash.doctor_create'));
83: return redirect(route('doctors.index'));
84: }
85: /**
86: * @return Application|Factory|View|RedirectResponse
87: *
88: * @throws Exception
89: */
90: public function show(Doctor $doctor)
91: {
92: if (getLogInUser()->hasRole('patient')) {
93: $doctorAppointment =
94: Appointment::whereDoctorId($doctor->id)->wherePatientId(getLogInUser()->patient->id);
95: if (! $doctorAppointment->exists()) {
96: return redirect()->back();
97: }
98: }
99: $doctorDetailData = $this->userRepo->doctorDetail($doctor);
100: return view('doctors.show', compact('doctor', 'doctorDetailData'));
101: }
102: /**
103: * Show the form for editing the specified resource.
104: *
105: * @return Application|Factory|View
106: */
107: public function edit(Doctor $doctor): \Illuminate\View\View
108: {
109: $user = $doctor->user()->first();
110: $qualifications = $user->qualifications()->get();
111: $data = $this->userRepo->getSpecializationsData($doctor);
112: $bloodGroup = Doctor::BLOOD_GROUP_ARRAY;
113: $countries = $this->userRepo->getCountries();
114: $state = $cities = null;
115: $years = [];
116: $currentYear = Carbon::now()->format('Y');
117: for ($year = 1960; $year <= $currentYear; $year++) {
118: $years[$year] = $year;
119: }
120: if (isset($countryId)) {
121: $state = getStates($data['countryId']->toArray());
122: }
123: if (isset($stateId)) {
124: $cities = getCities($data['stateId']->toArray());
125: }
126: return view('doctors.edit',
127: compact('user', 'qualifications', 'data', 'doctor', 'countries', 'state', 'cities',
128: 'years', 'bloodGroup'));
129: }
130: /**
131: * Update the specified resource in storage.
132: */
133: public function update(UpdateUserRequest $request, Doctor $doctor): JsonResponse
134: {
135: $input = $request->all();
136: $this->userRepo->update($input, $doctor);
137: Flash::success(__('messages.flash.doctor_update'));
138: return $this->sendSuccess(__('messages.flash.doctor_update'));
139: }
140: /**
141: * Remove the specified resource from storage.
142: */
143: public function destroy(Doctor $doctor): JsonResponse
144: {
145: $existAppointment = Appointment::whereDoctorId($doctor->id)->exists();
146: $existVisit = Visit::whereDoctorId($doctor->id)->exists();
147: if ($existAppointment || $existVisit) {
148: return $this->sendError(__('messages.flash.doctor_use'));
149: }
150: try {
151: DB::beginTransaction();
152: $doctor->user->delete();
153: $doctor->user->media()->delete();
154: $doctor->user->address()->delete();
155: $doctor->user->doctor()->delete();
156: DB::commit();
157: return $this->sendSuccess(__('messages.flash.doctor_delete'));
158: } catch (Exception $e) {
159: throw new UnprocessableEntityHttpException($e->getMessage());
160: }
161: }
162: /**
163: * @return Application|Factory|View
164: */
165: public function editProfile(): \Illuminate\View\View
166: {
167: $user = Auth::user();
168: return view('profile.index', compact('user'));
169: }
170: public function updateProfile(UpdateUserProfileRequest $request): RedirectResponse
171: {
172: $this->userRepo->updateProfile($request->all());
173: Flash::success(__('messages.flash.user_profile_update'));
174: return redirect(route('profile.setting'));
175: }
176: public function changePassword(UpdateChangePasswordRequest $request): JsonResponse
177: {
178: $input = $request->all();
179: try {
180: /** @var User $user */
181: $user = Auth::user();
182: if (! Hash::check($input['current_password'], $user->password)) {
183: return $this->sendError(__('messages.flash.current_invalid'));
184: }
185: $input['password'] = Hash::make($input['new_password']);
186: $user->update($input);
187: return $this->sendSuccess(__('messages.flash.password_update'));
188: } catch (Exception $e) {
189: throw new UnprocessableEntityHttpException($e->getMessage());
190: }
191: }
192: public function getStates(Request $request): JsonResponse
193: {
194: $countryId = $request->data;
195: $states = getStates($countryId);
196: return $this->sendResponse($states, __('messages.flash.retrieve'));
197: }
198: public function getCity(Request $request): JsonResponse
199: {
200: $state = $request->state;
201: $cities = getCities($state);
202: return $this->sendResponse($cities, __('messages.flash.retrieve'));
203: }
204: /**
205: * @return mixed
206: */
207: public function sessionData(Request $request)
208: {
209: $doctorSession = DoctorSession::whereDoctorId($request->doctorId)->first();
210: return $this->sendResponse($doctorSession, __('messages.flash.session_retrieve'));
211: }
212: /**
213: * @return mixed
214: */
215: public function addQualification(CreateQualificationRequest $request, Doctor
$doctor)
216: {
217: $this->userRepo->addQualification($request->all());
218: return $this->sendSuccess(__('messages.flash.qualification_create'));
219: }
220: /**
221: * @return Application|RedirectResponse|Redirector
222: *
223: * @throws Exception
224: */
225: public function doctorAppointment(Doctor $doctor, Request $request)
226: {
227: if ($request->ajax()) {
228: return DataTables::of((new UserDataTable())->getAppointment($request->only([
229: 'status', 'doctorId', 'filter_date',
230: ])))->make(true);
231: }
232: return redirect(route('doctors.index'));
233: }
234: public function changeDoctorStatus(Request $request): JsonResponse
235: {
236: $doctor = User::findOrFail($request->id);
237: $doctor->update(['status' => ! $doctor->status]);
238: return $this->sendResponse($doctor, __('messages.flash.status_update'));
239: }
240: public function updateLanguage(Request $request): JsonResponse
241: {
242: $language = $request->get('language');
243: $user = getLogInUser();
244: $user->update(['language' => $language]);
245: return $this->sendSuccess(__('messages.flash.language_update'));
246: }
247: public function impersonate(int $id): RedirectResponse
248: {
249: $user = User::findOrFail($id);
250: getLogInUser()->impersonate($user);
251: if ($user->hasRole('doctor')) {
252: return redirect()->route('doctors.dashboard');
253: } elseif ($user->hasRole('patient')) {
254: return redirect()->route('patients.dashboard');
255: }
256: return redirect()->route('admin.dashboard');
257: }
258: public function impersonateLeave(): RedirectResponse
259: {
260: getLogInUser()->leaveImpersonation();
261: return redirect()->route('admin.dashboard');
262: }
263: public function emailVerified(Request $request): JsonResponse
264: {
265: $user = User::findOrFail($request->id);
266: if ($request->value) {
267: $user->update([
268: 'email_verified_at' => Carbon::now(),
269: ]);
270: } else {
271: $user->update([
272: 'email_verified_at' => null,
273: ]);
274: }
275: return $this->sendResponse($user, __('messages.flash.verified_email'));
276: }
277: public function emailNotification(Request $request): JsonResponse
278: {
279: $input = $request->all();
280: $user = getLogInUser();
281: $user->update([
282: 'email_notification' => isset($input['email_notification']) ?
$input['email_notification']
283: : 0,
284: ]);
285: return $this->sendResponse($user, __('messages.flash.email_notification'));
286: }
287: public function resendEmailVerification($userId): JsonResponse
288: {
289: $user = User::findOrFail($userId);
290: if ($user->hasVerifiedEmail()) {
291: return $this->sendError(__('messages.flash.user_already_verified'));
292: }
293: $user->sendEmailVerificationNotification();
294: return $this->sendSuccess(__('messages.flash.notification_send'));
295: }
296: public function updateDarkMode(): JsonResponse
297: {
298: $user = Auth::user();
299: $darkEnabled = $user->dark_mode == true;
300: $user->update([
301: 'dark_mode' => ! $darkEnabled,
302: ]);
303: return $this->sendSuccess(__('messages.flash.theme_change'));
304: }
305: }
[Http > Controllers > VisitController.php]
1: <?php
2: namespace App\Http\Controllers;
3: use App\Http\Requests\CreateVisitPrescriptionRequest;
4: use App\Http\Requests\CreateVisitRequest;
5: use App\Http\Requests\UpdateVisitRequest;
6: use App\Models\Visit;
7: use App\Models\VisitNote;
8: use App\Models\VisitObservation;
9: use App\Models\VisitPrescription;
10: use App\Models\VisitProblem;
11: use App\Repositories\VisitRepository;
12: use Flash;
13: use Illuminate\Contracts\Foundation\Application;
14: use Illuminate\Contracts\View\Factory;
15: use Illuminate\Contracts\View\View;
16: use Illuminate\Http\RedirectResponse;
17: use Illuminate\Http\Request;
18: use Illuminate\Routing\Redirector;
19: class VisitController extends AppBaseController
20: {
21: /** @var VisitRepository */
22: private $visitRepository;
23: public function __construct(VisitRepository $visitRepo)
24: {
25: $this->visitRepository = $visitRepo;
26: }
27: /**
28: * @return Application|Factory|View
29: */
30: public function index(): \Illuminate\View\View
31: {
32: return view('visits.index');
33: }
34: /**
35: * @return Application|Factory|View
36: */
37: public function create(): \Illuminate\View\View
38: {
39: $data = $this->visitRepository->getData();
40: return view('visits.create', compact('data'));
41: }
42: /**
43: * @return Application|RedirectResponse|Redirector
44: */
45: public function store(CreateVisitRequest $request): RedirectResponse
46: {
47: $input = $request->all();
48: $this->visitRepository->create($input);
49: Flash::success(__('messages.flash.visit_create'));
50: if (getLoginUser()->hasRole('doctor')) {
51: return redirect(route('doctors.visits.index'));
52: }
53: return redirect(route('visits.index'));
54: }
55: /**
56: * @return Application|Factory|View|RedirectResponse
57: */
58: public function show($id)
59: {
60: if (getLogInUser()->hasRole('doctor')) {
61: $doctor = Visit::whereId($id)->whereDoctorId(getLogInUser()->doctor->id);
62: if (! $doctor->exists()) {
63: return redirect()->back();
64: }
65: }
66: $visit = $this->visitRepository->getShowData($id);
67: return view('visits.show', compact('visit'));
68: }
69: /**
70: * @return Application|Factory|View
71: */
72: public function edit(Visit $visit)
73: {
74: if (getLogInUser()->hasRole('doctor')) {
75: $doctor = Visit::whereId($visit->id)->whereDoctorId(getLogInUser()->doctor->id);
76: if (! $doctor->exists()) {
77: return redirect(route('doctors.visits.index'));
78: }
79: }
80: $data = $this->visitRepository->getData();
81: return view('visits.edit', compact('data', 'visit'));
82: }
83: /**
84: * @return Application|RedirectResponse|Redirector
85: */
86: public function update(Visit $visit, UpdateVisitRequest $request): RedirectResponse
87: {
88: $input = $request->all();
89: $visit->update($input);
90: Flash::success(__('messages.flash.visit_update'));
91: if (getLoginUser()->hasRole('doctor')) {
92: return redirect(route('doctors.visits.index'));
93: }
94: return redirect(route('visits.index'));
95: }
96: public function destroy(Visit $visit): mixed
97: {
98: if (getLogInUser()->hasrole('doctor')) {
99: if ($visit->doctor_id !== getLogInUser()->doctor->id) {
100: return $this->sendError(__('messages.common.not_allow__assess_record'));
101: }
102: }
103: $visit->delete();
104: return $this->sendSuccess(__('messages.flash.visit_delete'));
105: }
106: /**
107: * @return mixed
108: */
109: public function addProblem(Request $request)
110: {
111: $input = $request->all();
112: $problem = VisitProblem::create(['problem_name' => $input['problem_name'],
'visit_id' =>
113: $input['visit_id']]);
114: $problemData = VisitProblem::whereVisitId($input['visit_id'])->get();
115: return $this->sendResponse($problemData, __('messages.flash.problem_added'));
116: }
117: /**
118: * @return mixed
119: */
120: public function deleteProblem($id)
121: {
122: $problem = VisitProblem::findOrFail($id);
123: $visitId = $problem->visit_id;
124: $problem->delete();
125: $problemData = VisitProblem::whereVisitId($visitId)->get();
126: return $this->sendResponse($problemData, __('messages.flash.problem_delete'));
127: }
128: /**
129: * @return mixed
130: */
131: public function addObservation(Request $request)
132: {
133: $input = $request->all();
134: $observation = VisitObservation::create([
135: 'observation_name' => $input['observation_name'], 'visit_id' => $input['visit_id'],
136: ]);
137: $observationData = VisitObservation::whereVisitId($input['visit_id'])->get();
138: return $this->sendResponse($observationData,
__('messages.flash.observation_added'));
139: }
140: /**
141: * @return mixed
142: */
143: public function deleteObservation($id)
144: {
145: $observation = VisitObservation::findOrFail($id);
146: $visitId = $observation->visit_id;
147: $observation->delete();
148: $observationData = VisitObservation::whereVisitId($visitId)->get();
149: return $this->sendResponse($observationData,
__('messages.flash.observation_delete'));
150: }
151: /**
152: * @return mixed
153: */
154: public function addNote(Request $request)
155: {
156: $input = $request->all();
157: $note = VisitNote::create(['note_name' => $input['note_name'], 'visit_id' =>
158: $input['visit_id']]);
159: $noteData = VisitNote::whereVisitId($input['visit_id'])->get();
160: return $this->sendResponse($noteData, __('messages.flash.note_added'));
161: }
162: /**
163: * @return mixed
164: */
165: public function deleteNote($id)
166: {
167: $note = VisitNote::findOrFail($id);
168: $visitId = $note->visit_id;
169: $note->delete();
170: $noteData = VisitNote::whereVisitId($visitId)->get();
171: return $this->sendResponse($noteData, __('messages.flash.note_delete'));
172: }
173: /**
174: * @return mixed
175: */
176: public function addPrescription(CreateVisitPrescriptionRequest $request)
177: {
178: $input = $request->all();
179: if (! empty($input['prescription_id'])) {
180: $prescription = VisitPrescription::findOrFail($input['prescription_id']);
181: $prescription->update($input);
182: $message = __('messages.flash.visit_prescription_update');
183: } else {
184: VisitPrescription::create($input);
185: $message = __('messages.flash.visit_prescription_added');
186: }
187: $visitPrescriptions = VisitPrescription::whereVisitId($input['visit_id'])->get();
188: return $this->sendResponse($visitPrescriptions, $message);
189: }
190: /**
191: * @return mixed
192: */
193: public function editPrescription($id)
194: {
195: $prescription = VisitPrescription::findOrFail($id);
196: return $this->sendResponse($prescription,
__('messages.flash.prescription_retrieved'));
197: }
198: /**
199: * @return mixed
200: */
201: public function deletePrescription($id)
202: {
203: $prescription = VisitPrescription::findOrFail($id);
204: $visitId = $prescription->visit_id;
205: $prescription->delete();
206: $prescriptionData = VisitPrescription::whereVisitId($visitId)->get();
207: return $this->sendResponse($prescriptionData,
__('messages.flash.prescription_delete'));
208: }
209: }
[Controllers > Auth > AuthenticatedSessionController.php]
1: <?php
2: namespace App\Http\Controllers\Auth;
3: use App\Http\Controllers\Controller;
4: use App\Http\Requests\Auth\LoginRequest;
5: use Illuminate\Http\RedirectResponse;
6: use Illuminate\Http\Request;
7: use Illuminate\Support\Facades\Auth;
8: use Illuminate\View\View;
9: use Illuminate\Support\Facades\Session;
10: use App\Models\User;
11: use App\Models\Setting;
12: class AuthenticatedSessionController extends Controller
13: {
14: /**
15: * Display the login view.
16: */
17: public function create(): View
18: {
19: return view('auth.login');
20: }
21: /**
22: * Handle an incoming authentication request.
23: */
24: public function store(LoginRequest $request): RedirectResponse
25: {
26: $request->authenticate();
27: $request->session()->regenerate();
28: return redirect()->intended(getDashboardURL());
29: }
30: /**
31: * Destroy an authenticated session.
32: */
33: public function destroy(Request $request): RedirectResponse
34: {
35: $language = Setting::where('key','language')->get()->toArray()[0]['value'];
36: Auth::guard('web')->logout();
37: $request->session()->invalidate();
38: $request->session()->regenerateToken();
39: Session::put('languageName', $language);
40: return redirect('/');
41: }
42: }
[Controllers > Auth > ConfirmablePasswordController.php]
1: <?php
2: namespace App\Http\Controllers\Auth;
3: use App\Http\Controllers\Controller;
4: use App\Providers\RouteServiceProvider;
5: use Illuminate\Http\RedirectResponse;
6: use Illuminate\Http\Request;
7: use Illuminate\Support\Facades\Auth;
8: use Illuminate\Validation\ValidationException;
9: use Illuminate\View\View;
10: class ConfirmablePasswordController extends Controller
11: {
12: /**
13: * Show the confirm password view.
14: */
15: public function show(): View
16: {
17: return view('auth.confirm-password');
18: }
19: /**
20: * Confirm the user's password.
21: */
22: public function store(Request $request): RedirectResponse
23: {
24: if (! Auth::guard('web')->validate([
25: 'email' => $request->user()->email,
26: 'password' => $request->password,
27: ])) {
28: throw ValidationException::withMessages([
29: 'password' => __('auth.password'),
30: ]);
31: }
32: $request->session()->put('auth.password_confirmed_at', time());
33: return redirect()->intended(RouteServiceProvider::HOME);
34: }
35: }
[Controllers > Auth >
EmailVerificationNotificationController.php]
1: <?php
2: namespace App\Http\Controllers\Auth;
3: use App\Http\Controllers\Controller;
4: use App\Providers\RouteServiceProvider;
5: use Illuminate\Http\RedirectResponse;
6: use Illuminate\Http\Request;
7: class EmailVerificationNotificationController extends Controller
8: {
9: /**
10: * Send a new email verification notification.
11: */
12: public function store(Request $request): RedirectResponse
13: {
14: if ($request->user()->hasVerifiedEmail()) {
15: return redirect()->intended(RouteServiceProvider::HOME);
16: }
17: $request->user()->sendEmailVerificationNotification();
18: return back()->with('status', 'verification-link-sent');
19: }
20: }
[Controllers > Auth > EmailVerificationPromptController.php]
1: <?php
2: namespace App\Http\Controllers\Auth;
3: use App\Http\Controllers\Controller;
4: use App\Providers\RouteServiceProvider;
5: use Illuminate\Http\Request;
6: class EmailVerificationPromptController extends Controller
7: {
8: /**
9: * Display the email verification prompt.
10: *
11: * @return mixed
12: */
13: public function __invoke(Request $request)
14: {
15: return $request->user()->hasVerifiedEmail()
16: ? redirect()->intended(RouteServiceProvider::HOME)
17: : view('auth.verify-email');
18: }
19: }
[Controllers > Auth > NewPasswordController.php]
1: <?php
2: namespace App\Http\Controllers\Auth;
3: use App\Http\Controllers\Controller;
4: use Illuminate\Auth\Events\PasswordReset;
5: use Illuminate\Http\RedirectResponse;
6: use Illuminate\Http\Request;
7: use Illuminate\Support\Facades\Hash;
8: use Illuminate\Support\Facades\Password;
9: use Illuminate\Support\Str;
10: use Illuminate\Validation\Rules;
11: use Illuminate\View\View;
12: class NewPasswordController extends Controller
13: {
14: /**
15: * Display the password reset view.
16: */
17: public function create(Request $request): View
18: {
19: return view('auth.reset-password', ['request' => $request]);
20: }
21: /**
22: * Handle an incoming new password request.
23: *
24: *
25: * @throws \Illuminate\Validation\ValidationException
26: */
27: public function store(Request $request): RedirectResponse
28: {
29: $request->validate([
30: 'token' => 'required',
31: 'email' => 'required|email',
32: 'password' => ['required', 'confirmed', Rules\Password::defaults()],
33: ]);
34: // Here we will attempt to reset the user's password. If it is successful we
35: // will update the password on an actual user model and persist it to the
36: // database. Otherwise we will parse the error and return the response.
37: $status = Password::reset(
38: $request->only('email', 'password', 'password_confirmation', 'token'),
39: function ($user) use ($request) {
40: $user->forceFill([
41: 'password' => Hash::make($request->password),
42: 'remember_token' => Str::random(60),
43: ])->save();
44: event(new PasswordReset($user));
45: }
46: );
47: // If the password was successfully reset, we will redirect the user back to
48: // the application's home authenticated view. If there is an error we can
49: // redirect them back to where they came from with their error message.
50: return $status == Password::PASSWORD_RESET
51: ? redirect()->route('login')->with('status', __($status))
52: : back()->withInput($request->only('email'))
53: ->withErrors(['email' => __($status)]);
54: }
55: }
[Controllers > Auth > PasswordResetLinkController.php]
1: <?php
2: namespace App\Http\Controllers\Auth;
3: use App\Http\Controllers\Controller;
4: use Flash;
5: use Illuminate\Http\RedirectResponse;
6: use Illuminate\Http\Request;
7: use Illuminate\Support\Facades\Password;
8: use Illuminate\View\View;
9: class PasswordResetLinkController extends Controller
10: {
11: /**
12: * Display the password reset link request view.
13: */
14: public function create(): View
15: {
16: return view('auth.forgot-password');
17: }
18: /**
19: * Handle an incoming password reset link request.
20: *
21: *
22: * @throws \Illuminate\Validation\ValidationException
23: */
24: public function store(Request $request): RedirectResponse
25: {
26: $request->validate([
27: 'email' => 'required|email',
28: ]);
29: // We will send the password reset link to this user. Once we have attempted
30: // to send the link, we will examine the response then see the message we
31: // need to show to the user. Finally, we'll send out a proper response.
32: $status = Password::sendResetLink(
33: $request->only('email')
34: );
35: Flash::success(__('messages.flash.email_send'));
36: return $status == Password::RESET_LINK_SENT
37: ? back()->with('status', __($status))
38: : back()->withInput($request->only('email'))
39: ->withErrors(['email' => __($status)]);
40: }
41: }
[Controllers > Auth > RegisteredUserController.php]
1: <?php
2: namespace App\Http\Controllers\Auth;
3: use App\Http\Controllers\Controller;
4: use App\Models\Patient;
5: use App\Models\User;
6: use Illuminate\Http\RedirectResponse;
7: use Illuminate\Http\Request;
8: use Illuminate\Support\Facades\Hash;
9: use Illuminate\View\View;
10: use Laracasts\Flash\Flash;
11: class RegisteredUserController extends Controller
12: {
13: /**
14: * Display the registration view.
15: */
16: public function create(): View
17: {
18: return view('auth.register');
19: }
20: /**
21: * Handle an incoming registration request.
22: */
23: public function store(Request $request): RedirectResponse
24: {
25: $request->validate([
26: 'first_name' => 'required|string|max:255',
27: 'last_name' => 'required|string|max:255',
28: 'email' =>
29: 'required|email|max:255|regex:/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[
a-z]{2,6}$/ix|unique:users,email',
30: 'password' => ['required', 'confirmed', 'min:6'],
31: 'toc' => 'required',
32: ]);
33: $user = User::create([
34: 'first_name' => $request->first_name,
35: 'last_name' => $request->last_name,
36: 'email' => $request->email,
37: 'password' => Hash::make($request->password),
38: 'type' => User::PATIENT,
39: 'language' => getSettingValue('language'),
40: ]);
41: $user->patient()->create([
42: 'patient_unique_id' => mb_strtoupper(Patient::generatePatientUniqueId()),
43: ]);
44: $user->assignRole('patient');
45: $user->sendEmailVerificationNotification();
46: Flash::success(__('messages.flash.your_reg_success'));
47: return redirect('login');
48: }
49: }
[Controllers > Auth > VerifyEmailController.php]
1: <?php
2: namespace App\Http\Controllers\Auth;
3: use App\Http\Controllers\Controller;
4: use Illuminate\Auth\Events\Verified;
5: use Illuminate\Foundation\Auth\EmailVerificationRequest;
6: use Illuminate\Http\RedirectResponse;
7: class VerifyEmailController extends Controller
8: {
9: /**
10: * Mark the authenticated user's email address as verified.
11: */
12: public function __invoke(EmailVerificationRequest $request): RedirectResponse
13: {
14: if ($request->user()->hasVerifiedEmail()) {
15: return redirect()->intended(getDashboardURL().'?verified=1');
16: }
17: if ($request->user()->markEmailAsVerified()) {
18: event(new Verified($request->user()));
19: }
20: return redirect()->intended(getDashboardURL().'?verified=1');
21: }
22: }
[Controllers > Front > CMSController.php]
1: <?php
2: namespace App\Http\Controllers\Front;
3: use App\Http\Controllers\AppBaseController;
4: use App\Http\Requests\UpdateFrontCmsRequest;
5: use App\Models\Setting;
6: use Illuminate\Contracts\Foundation\Application;
7: use Illuminate\Contracts\View\Factory;
8: use Illuminate\Contracts\View\View;
9: use Illuminate\Http\RedirectResponse;
10: use Illuminate\Routing\Redirector;
11: use Laracasts\Flash\Flash;
12: class CMSController extends AppBaseController
13: {
14: /**
15: * Display a listing of the resource.
16: *
17: * @return Application|Factory|View
18: */
19: public function index(): \Illuminate\View\View
20: {
21: $cmsData = Setting::pluck('value', 'key')->toArray();
22: return view('fronts.cms.cms', compact('cmsData'));
23: }
24: /**
25: * @return Application|RedirectResponse|Redirector
26: */
27: public function update(UpdateFrontCmsRequest $request): RedirectResponse
28: {
29: $data = [];
30: $input = $request->all();
31: $data['terms_conditions'] = json_decode($input['terms_conditions']);
32: $data['privacy_policy'] = json_decode($input['privacy_policy']);
33: $data['about_title'] = $input['about_title'];
34: $data['about_short_description'] = $input['about_short_description'];
35: $data['about_experience'] = $input['about_experience'];
36: if (isset($input['about_image_1'])) {
37: $setting = Setting::where('key', 'about_image_1')->first();
38: $setting->clearMediaCollection(Setting::IMAGE);
39: $media =
$setting->addMedia($input['about_image_1'])->toMediaCollection(Setting::IMAGE,
40: config('app.media_disc'));
41: $setting->update(['value' => $media->getUrl()]);
42: }
43: if (isset($input['about_image_2'])) {
44: $setting = Setting::where('key', 'about_image_2')->first();
45: $setting->clearMediaCollection(Setting::IMAGE);
46: $media =
$setting->addMedia($input['about_image_2'])->toMediaCollection(Setting::IMAGE,
47: config('app.media_disc'));
48: $setting->update(['value' => $media->getUrl()]);
49: }
50: if (isset($input['about_image_3'])) {
51: $setting = Setting::where('key', 'about_image_3')->first();
52: $setting->clearMediaCollection(Setting::IMAGE);
53: $media =
$setting->addMedia($input['about_image_3'])->toMediaCollection(Setting::IMAGE,
54: config('app.media_disc'));
55: $setting->update(['value' => $media->getUrl()]);
56: }
57: foreach ($data as $key => $value) {
58: /** @var Setting $setting */
59: $setting = Setting::where('key', $key)->first();
60: if (! $setting) {
61: continue;
62: }
63: $setting->update(['value' => $value]);
64: }
65: Flash::success(__('messages.flash.cms_update'));
66: return redirect(route('cms.index'));
67: }
68: }
[Controllers > Front > EnquiryController.php]
1: <?php
2: namespace App\Http\Controllers\Front;
3: use App\DataTables\EnquiryDataTable;
4: use App\Http\Controllers\AppBaseController;
5: use App\Http\Requests\CreateEnquiryRequest;
6: use App\Mail\EnquiryMails;
7: use App\Models\Enquiry;
8: use DataTables;
9: use Illuminate\Contracts\Foundation\Application;
10: use Illuminate\Contracts\View\Factory;
11: use Illuminate\Contracts\View\View;
12: use Illuminate\Http\Request;
13: use Illuminate\Support\Facades\DB;
14: use Illuminate\Support\Facades\Mail;
15: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
16: class EnquiryController extends AppBaseController
17: {
18: /**
19: * @return Application|Factory|View
20: */
21: public function index(Request $request)
22: {
23: if ($request->ajax()) {
24: return DataTables::of((new
25: EnquiryDataTable())->get($request->only('status')))->make('true');
26: }
27: $status = Enquiry::VIEW_NAME;
28: return view('fronts.enquiries.index', compact('status'));
29: }
30: /**
31: * Store a newly created resource in storage.
32: *
33: * @return void
34: */
35: public function store(CreateEnquiryRequest $request)
36: {
37: try {
38: DB::beginTransaction();
39: $input = $request->all();
40: $input['email'] = setEmailLowerCase($input['email']);
41: Enquiry::create($input);
42: $input['appName'] = getAppName();
43: Mail::to($input['email'])
44: ->send(new EnquiryMails('emails.enquiry.enquiry', __('messages.flash.enquire_sent'),
45: $input));
46: DB::commit();
47: return $this->sendSuccess(__('messages.flash.messages_sent'));
48: } catch (\Exception $e) {
49: DB::rollBack();
50: throw new UnprocessableEntityHttpException($e->getMessage());
51: }
52: }
53: /**
54: * @return Application|Factory|View
55: */
56: public function show(Enquiry $enquiry): \Illuminate\View\View
57: {
58: $enquiry->update(['view' => isset($enquiry->view) ?? true]);
59: return view('fronts.enquiries.show', compact('enquiry'));
60: }
61: /**
62: * @return mixed
63: */
64: public function destroy(Enquiry $enquiry)
65: {
66: $enquiry->delete();
67: return $this->sendSuccess(__('messages.flash.enquire_deleted'));
68: }
69: }
[Controllers > Front > FaqController.php]
1: <?php
2: namespace App\Http\Controllers\Front;
3: use App\DataTables\FaqDataTable;
4: use App\Http\Controllers\AppBaseController;
5: use App\Http\Requests\CreateFaqRequest;
6: use App\Http\Requests\UpdateFaqRequest;
7: use App\Models\Faq;
8: use App\Repositories\FaqRepository;
9: use Datatables;
10: use Flash;
11: use Illuminate\Contracts\Foundation\Application;
12: use Illuminate\Contracts\View\Factory;
13: use Illuminate\Contracts\View\View;
14: use Illuminate\Http\RedirectResponse;
15: use Illuminate\Http\Request;
16: use Illuminate\Http\Response;
17: use Illuminate\Routing\Redirector;
18: class FaqController extends AppBaseController
19: {
20: /** @var FaqRepository */
21: private $faqRepository;
22: public function __construct(FaqRepository $faqRepo)
23: {
24: $this->faqRepository = $faqRepo;
25: }
26: /**
27: * Display a listing of the Faq.
28: *
29: * @return Application|Factory|View|Response
30: */
31: public function index(Request $request)
32: {
33: if ($request->ajax()) {
34: return Datatables::of((new FaqDataTable())->get())->make(true);
35: }
36: return view('fronts.faqs.index');
37: }
38: /**
39: * Show the form for creating a new Faq.
40: *
41: * @return Application|Factory|View
42: */
43: public function create(): \Illuminate\View\View
44: {
45: return view('fronts.faqs.create');
46: }
47: /**
48: * Store a newly created Faq in storage.
49: *
50: * @return Application|Redirector|RedirectResponse
51: */
52: public function store(CreateFaqRequest $request): RedirectResponse
53: {
54: $input = $request->all();
55: $faq = $this->faqRepository->create($input);
56: Flash::success(__('messages.flash.faq_creat'));
57: return redirect(route('faqs.index'));
58: }
59: /**
60: * Show the form for editing the specified Faq.
61: *
62: * @return Application|Factory|View
63: */
64: public function edit(Faq $faq): \Illuminate\View\View
65: {
66: return view('fronts.faqs.edit', compact('faq'));
67: }
68: /**
69: * Update the specified Faq in storage.
70: *
71: * @return Application|Redirector|RedirectResponse
72: */
73: public function update(UpdateFaqRequest $request, Faq $faq): RedirectResponse
74: {
75: $faq = $this->faqRepository->update($request->all(), $faq->id);
76: Flash::success(__('messages.flash.faq_update'));
77: return redirect(route('faqs.index'));
78: }
79: /**
80: * Remove the specified Faq from storage.
81: */
82: public function destroy(Faq $faq)
83: {
84: if ($faq->is_default) {
85: return $this->sendError(__('messages.flash.faq_use'));
86: }
87: $faq->delete();
88: return $this->sendSuccess(__('messages.flash.faq_delete'));
89: }
90: }
[Controllers > Front > FrontController.php]
1: <?php
2: namespace App\Http\Controllers\Front;
3: use App\Http\Controllers\AppBaseController;
4: use App\Models\ClinicSchedule;
5: use App\Models\Doctor;
6: use App\Models\DoctorSession;
7: use App\Models\Faq;
8: use App\Models\FrontPatientTestimonial;
9: use App\Models\Patient;
10: use App\Models\Service;
11: use App\Models\ServiceCategory;
12: use App\Models\Setting;
13: use App\Models\Slider;
14: use App\Models\Specialization;
15: use App\Models\User;
16: use Illuminate\Contracts\Foundation\Application;
17: use Illuminate\Contracts\View\Factory;
18: use Illuminate\Contracts\View\View;
19: use Illuminate\Database\Eloquent\Builder;
20: use Illuminate\Http\Request;
21: use Illuminate\Support\Facades\Session;
22: class FrontController extends AppBaseController
23: {
24: /**
25: * @return Application|Factory|View
26: */
27: public function medical(): \Illuminate\View\View
28: {
29: $doctors = Doctor::with('user', 'specializations')->whereHas('user', function
(Builder
30: $query) {
31: $query->where('status', User::ACTIVE);
32: })->latest()->take(10)->get()->pluck('user.full_name', 'id');
33: $sliders = Slider::with('media')->first();
34: $frontMedicalServicesArray =
35: Service::with('media')->whereStatus(Service::ACTIVE)->latest()->get()->toArray();
36: $frontMedicalServices = array_chunk($frontMedicalServicesArray, 2);
37: $frontPatientTestimonials =
38: FrontPatientTestimonial::with('media')->latest()->take(6)->get();
39: $aboutExperience = Setting::where('key', 'about_experience')->first();
40: return view('fronts.medicals.index',
41: compact('doctors', 'sliders', 'frontMedicalServices', 'frontPatientTestimonials',
42: 'aboutExperience'));
43: }
44: /**
45: * @return Application|Factory|View
46: */
47: public function medicalAboutUs(): \Illuminate\View\View
48: {
49: $data = [];
50: $data['doctorsCount'] = Doctor::with('user')->get()->where('user.status',
true)->count();
51: $data['patientsCount'] = Patient::get()->count();
52: $data['servicesCount'] = Service::whereStatus(true)->get()->count();
53: $data['specializationsCount'] = Specialization::get()->count();
54: $clinicSchedules = ClinicSchedule::all();
55: $setting = Setting::where('key', 'about_us_image')->first();
56: $frontPatientTestimonials =
57: FrontPatientTestimonial::with('media')->latest()->take(6)->get();
58: $doctors = Doctor::with('user', 'appointments', 'specializations')->whereHas('user',
59: function (Builder $query) {
60: $query->where('status', User::ACTIVE);
61: })->withCount('appointments')->orderBy('appointments_count', 'desc')->take(3)->get();
62: return view('fronts.medical_about_us',
63: compact('doctors', 'data', 'setting', 'clinicSchedules',
'frontPatientTestimonials'));
64: }
65: /**
66: * @return Application|Factory|View
67: */
68: public function medicalServices(): \Illuminate\View\View
69: {
70: $data = [];
71: $serviceCategories =
72: ServiceCategory::with('activatedServices')->withCount('services')->get();
73: $setting = Setting::pluck('value', 'key')->toArray();
74: $services = Service::with('media')->whereStatus(Service::ACTIVE)->latest()->get();
75: $data['doctorsCount'] = Doctor::with('user')->get()->where('user.status',
true)->count();
76: $data['patientsCount'] = Patient::get()->count();
77: $data['servicesCount'] = Service::whereStatus(true)->get()->count();
78: $data['specializationsCount'] = Specialization::get()->count();
79: return view('fronts.medical_services', compact('serviceCategories', 'setting',
'services',
80: 'data'));
81: }
82: /**
83: * @return Application|Factory|View
84: */
85: public function medicalAppointment(): \Illuminate\View\View
86: {
87: $faqs = Faq::latest()->get();
88: $appointmentDoctors = Doctor::with('user')->whereIn('id',
89: DoctorSession::pluck('doctor_id')->toArray())->get()->where('user.status',
90: User::ACTIVE)->pluck('user.full_name', 'id');
91: return view('fronts.medical_appointment', compact('faqs', 'appointmentDoctors'));
92: }
93: /**
94: * @return Application|Factory|View
95: */
96: public function medicalDoctors(): \Illuminate\View\View
97: {
98: $doctors = Doctor::with('specializations', 'user')->whereHas('user', function
(Builder
99: $query) {
100: $query->where('status', User::ACTIVE);
101: })->latest()->take(9)->get();
102: return view('fronts.medical_doctors', compact('doctors'));
103: }
104: /**
105: * @return Application|Factory|View
106: */
107: public function medicalContact(): \Illuminate\View\View
108: {
109: $clinicSchedules = ClinicSchedule::all();
110: return view('fronts.medical_contact', compact('clinicSchedules'));
111: }
112: /**
113: * @return Application|Factory|View
114: */
115: public function termsCondition(): \Illuminate\View\View
116: {
117: $termConditions = Setting::pluck('value', 'key')->toArray();
118: return view('fronts.terms_conditions', compact('termConditions'));
119: }
120: /**
121: * @return Application|Factory|View
122: */
123: public function privacyPolicy(): \Illuminate\View\View
124: {
125: $privacyPolicy = Setting::pluck('value', 'key')->toArray();
126: return view('fronts.privacy_policy', compact('privacyPolicy'));
127: }
128: /**
129: * @return Application|Factory|View
130: */
131: public function faq(): \Illuminate\View\View
132: {
133: $faqs = Faq::latest()->get();
134: return view('fronts.faq', compact('faqs'));
135: }
136: /**
137: * @return mixed
138: */
139: public function changeLanguage(Request $request)
140: {
141: Session::put('languageName', $request->input('languageName'));
142: return $this->sendSuccess(__('messages.flash.language_change'));
143: }
144: }
[Controllers > Front > FrontPatientTestimonialController.php]
1: <?php
2: namespace App\Http\Controllers\Front;
3: use App\DataTables\FrontPatientTestimonialDataTable;
4: use App\Http\Controllers\AppBaseController;
5: use App\Http\Requests\CreateFrontPatientTestimonialRequest;
6: use App\Http\Requests\UpdateFrontPatientTestimonialRequest;
7: use App\Models\FrontPatientTestimonial;
8: use App\Repositories\FrontPatientTestimonialRepository;
9: use Datatables;
10: use Flash;
11: use Illuminate\Contracts\Foundation\Application;
12: use Illuminate\Contracts\View\Factory;
13: use Illuminate\Contracts\View\View;
14: use Illuminate\Http\RedirectResponse;
15: use Illuminate\Http\Request;
16: use Illuminate\Http\Response;
17: use Illuminate\Routing\Redirector;
18: class FrontPatientTestimonialController extends AppBaseController
19: {
20: /** @var FrontPatientTestimonialRepository */
21: private $frontPatientTestimonialRepository;
22: public function __construct(FrontPatientTestimonialRepository
23: $frontPatientTestimonialRepo)
24: {
25: $this->frontPatientTestimonialRepository = $frontPatientTestimonialRepo;
26: }
27: /**
28: * Display a listing of the FrontPatientTestimonial.
29: *
30: * @return Application|Factory|View|Response
31: */
32: public function index(Request $request)
33: {
34: if ($request->ajax()) {
35: return Datatables::of((new FrontPatientTestimonialDataTable())->get())->make(true);
36: }
37: return view('fronts.front_patient_testimonials.index');
38: }
39: /**
40: * Show the form for creating a new FrontPatientTestimonial.
41: *
42: * @return Application|Factory|View
43: */
44: public function create(): \Illuminate\View\View
45: {
46: return view('fronts.front_patient_testimonials.create');
47: }
48: /**
49: * Store a newly created FrontPatientTestimonial in storage.
50: *
51: * @return Application|Redirector|RedirectResponse
52: */
53: public function store(CreateFrontPatientTestimonialRequest $request):
RedirectResponse
54: {
55: $input = $request->all();
56: $frontPatientTestimonial = $this->frontPatientTestimonialRepository->store($input);
57: Flash::success(__('messages.flash.testimonial_creat'));
58: return redirect(route('front-patient-testimonials.index'));
59: }
60: /**
61: * Show the form for editing the specified FrontPatientTestimonial.
62: *
63: * @return Application|Factory|View
64: */
65: public function edit(FrontPatientTestimonial $frontPatientTestimonial):
66: \Illuminate\View\View
67: {
68: return view('fronts.front_patient_testimonials.edit',
compact('frontPatientTestimonial'));
69: }
70: /**
71: * Update the specified FrontPatientTestimonial in storage.
72: *
73: * @return Application|Redirector|RedirectResponse
74: */
75: public function update(
76: UpdateFrontPatientTestimonialRequest $request,
77: FrontPatientTestimonial $frontPatientTestimonial
78: ): RedirectResponse {
79: $frontPatientTestimonial =
80: $this->frontPatientTestimonialRepository->update($request->all(),
81: $frontPatientTestimonial->id);
82: Flash::success(__('messages.flash.testimonial_update'));
83: return redirect(route('front-patient-testimonials.index'));
84: }
85: /**
86: * Remove the specified FrontPatientTestimonial from storage.
87: */
88: public function destroy(FrontPatientTestimonial $frontPatientTestimonial)
89: {
90: if ($frontPatientTestimonial->is_default) {
91: return $this->sendError(__('messages.flash.testimonial_use'));
92: }
93: $frontPatientTestimonial->delete();
94: return $this->sendSuccess(__('messages.flash.testimonial_delete'));
95: }
96: }
[Controllers > Front > SliderController.php]
1: <?php
2: namespace App\Http\Controllers\Front;
3: use App\DataTables\SliderDataTable;
4: use App\Http\Controllers\AppBaseController;
5: use App\Http\Requests\UpdateSliderRequest;
6: use App\Models\Slider;
7: use App\Repositories\SliderRepository;
8: use Datatables;
9: use Exception;
10: use Flash;
11: use Illuminate\Contracts\Foundation\Application;
12: use Illuminate\Contracts\View\Factory;
13: use Illuminate\Contracts\View\View;
14: use Illuminate\Http\RedirectResponse;
15: use Illuminate\Http\Request;
16: use Illuminate\Routing\Redirector;
17: class SliderController extends AppBaseController
18: {
19: /** @var SliderRepository */
20: private $sliderRepository;
21: public function __construct(SliderRepository $sliderRepo)
22: {
23: $this->sliderRepository = $sliderRepo;
24: }
25: /**
26: * Display a listing of the resource.
27: *
28: * @return Application|Factory|View
29: *
30: * @throws Exception
31: */
32: public function index(Request $request)
33: {
34: if ($request->ajax()) {
35: return DataTables::of((new SliderDataTable)->get())->make('true');
36: }
37: return view('fronts.sliders.index');
38: }
39: /**
40: * Show the form for editing the specified resource.
41: *
42: * @return Application|Factory|View
43: */
44: public function edit(Slider $banner): \Illuminate\View\View
45: {
46: return view('fronts.sliders.edit', compact('banner'));
47: }
48: /**
49: * Update the specified resource in storage.
50: *
51: * @return Application|RedirectResponse|Redirector
52: */
53: public function update(UpdateSliderRequest $request, Slider $banner):
RedirectResponse
54: {
55: $input = $request->all();
56: $banner = $this->sliderRepository->update($input, $banner->id);
57: Flash::success(__('messages.flash.slider_update'));
58: return redirect(route('banner.index'));
59: }
60: }
[Controllers > Front > SubscribeController.php]
1: <?php
2: namespace App\Http\Controllers\Front;
3: use App\DataTables\SubscriberDataTable;
4: use App\Http\Controllers\AppBaseController;
5: use App\Http\Requests\CreateSubscribeRequest;
6: use App\Models\Subscribe;
7: use DataTables;
8: use Illuminate\Contracts\Foundation\Application;
9: use Illuminate\Contracts\View\Factory;
10: use Illuminate\Contracts\View\View;
11: use Illuminate\Http\Request;
12: class SubscribeController extends AppBaseController
13: {
14: /**
15: * @return Application|Factory|View
16: */
17: public function index(Request $request)
18: {
19: if ($request->ajax()) {
20: return DataTables::of((new SubscriberDataTable())->get())->make('true');
21: }
22: return view('fronts.subscribers.index');
23: }
24: /**
25: * Store a newly created resource in storage.
26: *
27: * @return void
28: */
29: public function store(CreateSubscribeRequest $request)
30: {
31: $input = $request->all();
32: Subscribe::create([
33: 'email' => setEmailLowerCase($input['email']),
34: 'subscribe' => Subscribe::SUBSCRIBE,
35: ]);
36: return $this->sendSuccess(__('messages.flash.subscriber_creat'));
37: }
38: /**
39: * @return mixed
40: */
41: public function destroy(Subscribe $subscribe)
42: {
43: $subscribe->delete();
44: return $this->sendSuccess(__('messages.flash.subscriber_delete'));
45: }
46: }
[Http > Livewire > AppointmentTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use Carbon\Carbon;
4: use App\Models\User;
5: use App\Models\Patient;
6: use App\Models\Appointment;
7: use Illuminate\Database\Eloquent\Builder;
8: use Rappasoft\LaravelLivewireTables\Views\Column;
9: class AppointmentTable extends LivewireTableComponent
10: {
11: protected $model = Appointment::class;
12: public bool $showButtonOnHeader = true;
13: public string $buttonComponent = 'appointments.components.add_button';
14: public bool $showFilterOnHeader = true;
15: public array $FilterComponent = ['appointments.components.filter',
16: Appointment::PAYMENT_TYPE_ALL, Appointment::STATUS];
17: protected $listeners = [
18: 'refresh' => '$refresh', 'resetPage', 'changeStatusFilter',
'changePaymentTypeFilter',
19: 'changeDateFilter', 'changePaymentStatusFilter',
20: ];
21: public string $paymentTypeFilter = '';
22: public string $paymentStatusFilter = '';
23: public string $dateFilter = '';
24: public $statusFilter = Appointment::BOOKED;
25: public function configure(): void
26: {
27: $this->setPrimaryKey('id')
28: ->setDefaultSort('created_at', 'desc')
29: ->setQueryStringStatus(false);
30: $this->setThAttributes(function (Column $column) {
31: if ($column->isField('id')) {
32: return [
33: 'class' => 'text-center',
34: ];
35: }
36: return [];
37: });
38: }
39: public function builder(): Builder
40: {
41: $query = Appointment::with([
42: 'doctor.user', 'patient.user', 'services', 'transaction', 'doctor.reviews',
43: 'doctor.user.media',
44: ]);
45: $query->when($this->statusFilter != '' && $this->statusFilter !=
Appointment::ALL_STATUS,
46: function (Builder $q) {
47: if ($this->statusFilter != Appointment::ALL) {
48: $q->where('appointments.status', '=', $this->statusFilter);
49: }
50: });
51: $query->when($this->paymentTypeFilter != '' && $this->paymentTypeFilter !=
52: Appointment::ALL_PAYMENT,
53: function (Builder $q) {
54: $q->where('payment_type', '=', $this->paymentTypeFilter);
55: });
56: $query->when($this->paymentStatusFilter != '',
57: function (Builder $q) {
58: if ($this->paymentStatusFilter != Appointment::ALL_PAYMENT) {
59: if ($this->paymentStatusFilter == Appointment::PENDING) {
60: $q->has('transaction', '=', null);
61: } elseif ($this->paymentStatusFilter == Appointment::PAID) {
62: $q->has('transaction', '!=', null);
63: }
64: }
65: });
66: if ($this->dateFilter != '' && $this->dateFilter != getWeekDate()) {
67: $timeEntryDate = explode(' - ', $this->dateFilter);
68: $startDate = Carbon::parse($timeEntryDate[0])->format('Y-m-d');
69: $endDate = Carbon::parse($timeEntryDate[1])->format('Y-m-d');
70: $query->whereBetween('date', [$startDate, $endDate]);
71: } else {
72: $timeEntryDate = explode(' - ', getWeekDate());
73: $startDate = Carbon::parse($timeEntryDate[0])->format('Y-m-d');
74: $endDate = Carbon::parse($timeEntryDate[1])->format('Y-m-d');
75: $query->whereBetween('date', [$startDate, $endDate]);
76: }
77: if (getLoginUser()->hasRole('patient')) {
78: $query->where('patient_id', getLoginUser()->patient->id);
79: }
80: return $query->select('appointments.*');
81: }
82: public function changeStatusFilter($status)
83: {
84: $this->statusFilter = $status;
85: $this->setBuilder($this->builder());
86: }
87: public function changePaymentTypeFilter($type)
88: {
89: $this->paymentTypeFilter = $type;
90: $this->setBuilder($this->builder());
91: }
92: public function changePaymentStatusFilter($type)
93: {
94: $this->paymentTypeFilter = $type;
95: $this->setBuilder($this->builder());
96: }
97: public function changeDateFilter($date)
98: {
99: $this->dateFilter = $date;
100: $this->setBuilder($this->builder());
101: }
102: public function columns(): array
103: {
104: return [
105: Column::make(__('messages.visit.doctor'), 'doctor.doctorUser.first_name')
106: ->view('appointments.components.doctor_name')
107: ->sortable()
108: ->searchable(
109: function (Builder $query, $direction) {
110: return $query->whereHas('doctor.doctorUser', function (Builder $q) use ($direction)
{
111: $q->whereRaw("TRIM(CONCAT(first_name,' ',last_name,' ')) like '%{$direction}%'");
112: });
113: }
114: ),
115: Column::make(__('messages.appointment.patient'), 'patient.patientUser.first_name')
116: ->view('appointments.components.patient_name')
117: ->sortable(function (Builder $query, $direction) {
118: return $query->orderBy(User::select('first_name')->whereColumn('id',
'patients.user_id'),
119: $direction);
120: })
121: ->searchable(),
122: Column::make(__('messages.appointment.patient'), 'patient.patientUser.last_name')
123: ->hideIf('patient.patientUser.last_name')
124: ->searchable(),
125: Column::make(__('messages.appointment.patient'), 'patient.patientUser.email')
126: ->hideIf('patient.patientUser.email')
127: ->searchable(),
128: Column::make(__('messages.appointment.appointment_at'),
129: 'date')->view('appointments.components.appointment_at')
130: ->sortable()->searchable(),
131: Column::make(__('messages.common.action'),
'id')->view('appointments.components.action'),
132: ];
133: }
134: }
[Http > Livewire > CityTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\City;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class CityTable extends LivewireTableComponent
7: {
8: protected $model = City::class;
9: public bool $showButtonOnHeader = true;
10: public string $buttonComponent = 'cities.components.add_button';
11: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
12: public function configure(): void
13: {
14: $this->setPrimaryKey('id')
15: ->setDefaultSort('created_at', 'desc')
16: ->setQueryStringStatus(false);
17: $this->setThAttributes(function (Column $column) {
18: if ($column->isField('id')) {
19: return [
20: 'class' => 'text-center',
21: ];
22: }
23: return [];
24: });
25: }
26: public function builder(): Builder
27: {
28: return City::with('state')->select('cities.*');
29: }
30: public function columns(): array
31: {
32: return [
33: Column::make(__('messages.common.name'), 'name')->view('cities.components.name')
34: ->sortable()->searchable(),
35: Column::make(__('messages.city.state'),
'state.name')->view('cities.components.state')
36: ->sortable()->searchable(),
37: Column::make(__('messages.common.action'), 'id')->view('cities.components.action'),
38: ];
39: }
40: }
[Http > Livewire > CountriesTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Country;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class CountriesTable extends LivewireTableComponent
7: {
8: protected $model = Country::class;
9: public bool $showButtonOnHeader = true;
10: public string $buttonComponent = 'countries.components.add_button';
11: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
12: public function configure(): void
13: {
14: $this->setPrimaryKey('id')
15: ->setDefaultSort('created_at', 'desc')
16: ->setQueryStringStatus(false);
17: $this->setThAttributes(function (Column $column) {
18: if ($column->isField('id')) {
19: return [
20: 'class' => 'text-center',
21: ];
22: }
23: return [];
24: });
25: }
26: public function columns(): array
27: {
28: return [
29: Column::make(__('messages.common.name'), 'name')->view('countries.components.name')
30: ->searchable()
31: ->sortable(),
32: Column::make(__('messages.country.short_code'),
33: 'short_code')->view('countries.components.short_code')
34: ->sortable()
35: ->searchable(),
36: Column::make(__('messages.common.action'),
'id')->view('countries.components.action'),
37: ];
38: }
39: public function builder(): Builder
40: {
41: return Country::query();
42: }
43: }
[Http > Livewire > CurrenciesTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Currency;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class CurrenciesTable extends LivewireTableComponent
7: {
8: protected $model = Currency::class;
9: public bool $showButtonOnHeader = true;
10: public string $buttonComponent = 'currencies.components.add_button';
11: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
12: public function configure(): void
13: {
14: $this->setPrimaryKey('id')
15: ->setDefaultSort('created_at', 'desc')
16: ->setQueryStringStatus(false);
17: $this->setThAttributes(function (Column $column) {
18: if ($column->isField('id')) {
19: return [
20: 'class' => 'text-center',
21: ];
22: }
23: return [];
24: });
25: }
26: public function columns(): array
27: {
28: return [
29: Column::make(__('messages.currency.currency_name'),
30: 'currency_name')->view('currencies.components.name')
31: ->searchable()
32: ->sortable(),
33: Column::make(__('messages.currency.currency_icon'),
34: 'currency_icon')->view('currencies.components.icon')
35: ->searchable(),
36: Column::make(__('messages.currency.currency_code'),
37: 'currency_code')->view('currencies.components.code')
38: ->sortable()
39: ->searchable(),
40: Column::make(__('messages.common.action'),
'id')->view('currencies.components.action'),
41: ];
42: }
43: public function builder(): Builder
44: {
45: return Currency::query();
46: }
47: }
[Http > Livewire > DoctorAppointmentTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Appointment;
4: use Carbon\Carbon;
5: use Illuminate\Database\Eloquent\Builder;
6: use Rappasoft\LaravelLivewireTables\Views\Column;
7: class DoctorAppointmentTable extends LivewireTableComponent
8: {
9: public $doctorId;
10: protected $model = Appointment::class;
11: public bool $showFilterOnHeader = true;
12: public array $FilterComponent = ['doctor_appointment.components.filter',
13: Appointment::STATUS];
14: protected $listeners = ['refresh' => '$refresh', 'resetPage', 'changeStatusFilter',
15: 'changeDateFilter'];
16: public int $statusFilter = Appointment::BOOKED;
17: public string $dateFilter = '';
18: public function configure(): void
19: {
20: $this->setPrimaryKey('id')
21: ->setDefaultSort('created_at', 'desc')
22: ->setQueryStringStatus(false);
23: $this->setThAttributes(function (Column $column) {
24: if ($column->isField('id')) {
25: return [
26: 'class' => 'text-center',
27: ];
28: }
29: return [];
30: });
31: }
32: public function builder(): Builder
33: {
34: $query = Appointment::with(['patient.user'])->where('doctor_id', '=',
35: $this->doctorId)->select('appointments.*');
36: $query->when($this->statusFilter != '' && $this->statusFilter !=
Appointment::ALL_STATUS,
37: function (Builder $q) {
38: if ($this->statusFilter != Appointment::ALL) {
39: $q->where('appointments.status', '=', $this->statusFilter);
40: }
41: });
42: if ($this->dateFilter != '' && $this->dateFilter != getWeekDate()) {
43: $timeEntryDate = explode(' - ', $this->dateFilter);
44: $startDate = Carbon::parse($timeEntryDate[0])->format('Y-m-d');
45: $endDate = Carbon::parse($timeEntryDate[1])->format('Y-m-d');
46: $query->whereBetween('appointments.date', [$startDate, $endDate]);
47: } else {
48: $timeEntryDate = explode(' - ', getWeekDate());
49: $startDate = Carbon::parse($timeEntryDate[0])->format('Y-m-d');
50: $endDate = Carbon::parse($timeEntryDate[1])->format('Y-m-d');
51: $query->whereBetween('appointments.date', [$startDate, $endDate]);
52: }
53: return $query;
54: }
55: public function changeStatusFilter($status)
56: {
57: if ($status == null) {
58: $status = 1;
59: }
60: $this->statusFilter = $status;
61: $this->setBuilder($this->builder());
62: }
63: public function changeDateFilter($date)
64: {
65: $this->dateFilter = $date;
66: $this->setBuilder($this->builder());
67: }
68: public function columns(): array
69: {
70: return [
71: Column::make(__('messages.appointment.patient'),
72: 'patient.user.first_name')->view('doctor_appointment.components.patient')
73: ->sortable()
74: ->searchable(
75: function (Builder $query, $direction) {
76: return $query->whereHas('patient.user', function (Builder $q) use ($direction) {
77: $q->whereRaw("TRIM(CONCAT(first_name,' ',last_name,' ')) like '%{$direction}%'");
78: });
79: }
80: ),
81: Column::make(__('messages.appointment.appointment_at'),
82: 'date')->view('doctor_appointment.components.appointment_at')
83: ->sortable()->searchable(),
84: Column::make(__('messages.common.action'),
85: 'id')->view('doctor_appointment.components.action'),
86: ];
87: }
88: }
[Http > Livewire > DoctorHolidayTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\DoctorHoliday;
4: use Carbon\Carbon;
5: use Illuminate\Database\Eloquent\Builder;
6: use Rappasoft\LaravelLivewireTables\Views\Column;
7: class DoctorHolidayTable extends LivewireTableComponent
8: {
9: protected $model = DoctorHoliday::class;
10: public bool $showButtonOnHeader = true;
11: public string $buttonComponent = 'doctor_holiday.components.add_button';
12: public bool $showFilterOnHeader = true;
13: public array $FilterComponent = ['doctor_holiday.components.filter', []];
14: protected $listeners = ['refresh' => '$refresh', 'resetPage', 'changeDateFilter'];
15: public string $dateFilter = '';
16: public function configure(): void
17: {
18: $this->setPrimaryKey('id')
19: ->setDefaultSort('created_at', 'desc')
20: ->setQueryStringStatus(false);
21: }
22: /**
23: * @var string[]
24: */
25: public function changeDateFilter($date)
26: {
27: $this->dateFilter = $date;
28: $this->setBuilder($this->builder());
29: }
30: public function columns(): array
31: {
32: return [
33: Column::make(__('messages.visit.doctor'), 'doctor.doctorUser.first_name')
34: ->view('doctor_holiday.components.doctor')
35: ->sortable()
36: ->searchable(
37: function (Builder $query, $direction) {
38: return $query->whereHas('doctor.doctorUser', function (Builder $q) use ($direction) {
39: $q->whereRaw("TRIM(CONCAT(first_name,' ',last_name,' ')) like '%{$direction}%'");
40: });
41: }
42: ),
43: Column::make(__('messages.visit.doctor'), 'doctor.doctorUser.email')
44: ->hideIf('doctor.doctorUser.email')
45: ->searchable(),
46: Column::make(__('messages.web.reason'),
'name')->view('doctor_holiday.components.reason')
47: ->sortable(),
48: Column::make(__('messages.holiday.holiday_date'),
49: 'date')->view('doctor_holiday.components.holiday_date')
50: ->sortable(),
51: Column::make(__('messages.common.action'),
52: 'id')->view('doctor_holiday.components.action'),
53: ];
54: }
55: public function builder(): Builder
56: {
57: $query = DoctorHoliday::with('doctor')->select('doctor_holidays.*');
58: if ($this->dateFilter != '' && $this->dateFilter != getWeekDate()) {
59: $timeEntryDate = explode(' - ', $this->dateFilter);
60: $startDate = Carbon::parse($timeEntryDate[0])->format('Y-m-d');
61: $endDate = Carbon::parse($timeEntryDate[1])->format('Y-m-d');
62: $query->whereBetween('date', [$startDate, $endDate]);
63: } else {
64: $timeEntryDate = explode(' - ', getWeekDate());
65: $startDate = Carbon::parse($timeEntryDate[0])->format('Y-m-d');
66: $endDate = Carbon::parse($timeEntryDate[1])->format('Y-m-d');
67: $query->whereBetween('date', [$startDate, $endDate]);
68: }
69: return $query;
70: }
71: }
[Http > Livewire > DoctorPanelAppointmentTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Appointment;
4: use Carbon\Carbon;
5: use Illuminate\Database\Eloquent\Builder;
6: use Rappasoft\LaravelLivewireTables\Views\Column;
7: class DoctorPanelAppointmentTable extends LivewireTableComponent
8: {
9: protected $model = Appointment::class;
10: public bool $showFilterOnHeader = true;
11: public bool $showButtonOnHeader = true;
12: public array $FilterComponent = [
13: 'doctor_appointment.doctor_panel.components.filter', Appointment::PAYMENT_TYPE_ALL,
14: Appointment::STATUS,
15: ];
16: protected $listeners = [
17: 'refresh' => '$refresh', 'changeStatusFilter', 'changePaymentTypeFilter',
18: 'changeDateFilter', 'resetPage',
19: ];
20: public string $buttonComponent =
'doctor_appointment.doctor_panel.components.add_button';
21: public string $paymentTypeFilter = '';
22: public string $paymentStatusFilter = '';
23: public string $dateFilter = '';
24: public int $statusFilter = Appointment::BOOKED;
25: public function configure(): void
26: {
27: $this->setPrimaryKey('id')
28: ->setDefaultSort('created_at', 'desc')
29: ->setQueryStringStatus(false);
30: $this->setThAttributes(function (Column $column) {
31: if ($column->isField('id')) {
32: return [
33: 'class' => 'text-center',
34: ];
35: }
36: return [];
37: });
38: }
39: public function builder(): Builder
40: {
41: $query = Appointment::with(['patient.user', 'services',
42: 'transaction'])->where('doctor_id',
43: getLoginUser()->doctor->id)->select('appointments.*');
44: $query->when($this->statusFilter != '' && $this->statusFilter !=
Appointment::ALL_STATUS,
45: function (Builder $q) {
46: if ($this->statusFilter != Appointment::ALL) {
47: $q->where('appointments.status', '=', $this->statusFilter);
48: }
49: });
50: $query->when($this->paymentTypeFilter != '' && $this->paymentTypeFilter !=
51: Appointment::ALL_PAYMENT,
52: function (Builder $q) {
53: $q->where('appointments.payment_type', '=', $this->paymentTypeFilter);
54: });
55: if ($this->dateFilter != '' && $this->dateFilter != getWeekDate()) {
56: $timeEntryDate = explode(' - ', $this->dateFilter);
57: $startDate = Carbon::parse($timeEntryDate[0])->format('Y-m-d');
58: $endDate = Carbon::parse($timeEntryDate[1])->format('Y-m-d');
59: $query->whereBetween('appointments.date', [$startDate, $endDate]);
60: } else {
61: $timeEntryDate = explode(' - ', getWeekDate());
62: $startDate = Carbon::parse($timeEntryDate[0])->format('Y-m-d');
63: $endDate = Carbon::parse($timeEntryDate[1])->format('Y-m-d');
64: $query->whereBetween('appointments.date', [$startDate, $endDate]);
65: }
66: return $query;
67: }
68: public function changeStatusFilter($status)
69: {
70: $this->statusFilter = $status;
71: $this->setBuilder($this->builder());
72: }
73: public function changePaymentTypeFilter($type)
74: {
75: $this->paymentTypeFilter = $type;
76: $this->setBuilder($this->builder());
77: }
78: public function changeDateFilter($date)
79: {
80: $this->dateFilter = $date;
81: $this->setBuilder($this->builder());
82: }
83: public function columns(): array
84: {
85: return [
86: Column::make(__('messages.appointment.patient'),
87: 'patient.user.first_name')->view('doctor_appointment.doctor_panel.components.patient'
)
88: ->sortable()
89: ->searchable(
90: function (Builder $query, $direction) {
91: return $query->whereHas('patient.user', function (Builder $q) use ($direction) {
92: $q->whereRaw("TRIM(CONCAT(first_name,' ',last_name,' ')) like '%{$direction}%'");
93: });
94: }
95: ),
96: Column::make(__('messages.patient.name'), 'patient.user.email')
97: ->hideIf('patient.user.email')
98: ->searchable(),
99: Column::make(__('messages.appointment.appointment_at'),
100: 'date')->view('doctor_appointment.doctor_panel.components.appointment_at')
101: ->sortable()->searchable(),
102: Column::make(__('messages.appointment.service_charge'),
103: 'services.charges')->view('doctor_appointment.doctor_panel.components.service_charge
')
104: ->sortable()->searchable(),
105: Column::make(__('messages.appointment.payment'), 'id')
106: ->format(function ($value, $row) {
107: return view('doctor_appointment.doctor_panel.components.payment')
108: ->with([
109: 'row' => $row,
110: 'paid' => Appointment::PAID,
111: 'pending' => Appointment::PENDING,
112: ]);
113: }),
114: Column::make(__('messages.appointment.status'), 'id')
115: ->format(function ($value, $row) {
116: return view('doctor_appointment.doctor_panel.components.status')
117: ->with([
118: 'row' => $row,
119: 'book' => Appointment::BOOKED,
120: 'checkIn' => Appointment::CHECK_IN,
121: 'checkOut' => Appointment::CHECK_OUT,
122: 'cancel' => Appointment::CANCELLED,
123: ]);
124: }),
125: Column::make(__('messages.common.action'),
126: 'id')->view('doctor_appointment.doctor_panel.components.action'),
127: ];
128: }
129: }
[Http > Livewire > DoctorScheduleTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\DoctorSession;
4: use App\Models\User;
5: use Illuminate\Database\Eloquent\Builder;
6: use Rappasoft\LaravelLivewireTables\Views\Column;
7: class DoctorScheduleTable extends LivewireTableComponent
8: {
9: protected $model = DoctorSession::class;
10: public bool $showButtonOnHeader = true;
11: public string $buttonComponent = 'doctor_sessions.components.add_button';
12: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
13: public function configure(): void
14: {
15: $this->setPrimaryKey('id')
16: ->setDefaultSort('created_at', 'desc')
17: ->setQueryStringStatus(false);
18: $this->setThAttributes(function (Column $column) {
19: if ($column->isField('id')) {
20: return [
21: 'class' => 'text-center',
22: ];
23: }
24: return [];
25: });
26: }
27: public function columns(): array
28: {
29: return [
30: Column::make(__('messages.doctor.doctor'),
31: 'doctor.user.first_name')->view('doctor_sessions.components.doctor_name')
32: ->sortable(
33: // function (Builder $query, $direction) {
34: // return $query->whereHas('doctor.user', function (Builder
$q) use
35: ($direction) {
36: //
37: $q->orderBy(User::select('first_name')->whereColumn('users.id', 'user_id'),
$direction);
38: // });
39: // }
40: )->searchable(
41: function (Builder $query, $direction) {
42: return $query->whereHas('doctor.user', function (Builder $q) use ($direction) {
43: $q->whereRaw("TRIM(CONCAT(first_name,' ',last_name,' ')) like '%{$direction}%'");
44: });
45: }
46: ),
47: Column::make(__('messages.doctor_session.session_meeting_time'),
48: 'session_meeting_time')->view('doctor_sessions.components.schedule_meeting_time')
49: ->sortable()->searchable(),
50: Column::make(__('messages.common.action'),
51: 'id')->view('doctor_sessions.components.action'),
52: ];
53: }
54: public function builder(): Builder
55: {
56: $query = DoctorSession::with(['doctor.user',
57: 'doctor.reviews'])->select('doctor_sessions.*');
58: if (getLoginUser()->hasRole('doctor')) {
59: $query->where('doctor_id', getLoginUser()->doctor->id);
60: }
61: return $query;
62: }
63: }
[Http > Livewire > DoctorsTransactionTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Appointment;
4: use App\Models\Transaction;
5: use Illuminate\Database\Eloquent\Builder;
6: use Rappasoft\LaravelLivewireTables\Views\Column;
7: class DoctorsTransactionTable extends LivewireTableComponent
8: {
9: protected $model = Transaction::class;
10: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
11: public function configure(): void
12: {
13: $this->setPrimaryKey('id')
14: ->setDefaultSort('created_at', 'desc')
15: ->setQueryStringStatus(false);
16: $this->setThAttributes(function (Column $column) {
17: if ($column->isField('id')) {
18: return [
19: 'class' => 'text-center',
20: ];
21: }
22: if ($column->isField('amount')) {
23: return [
24: 'class' => 'text-end',
25: ];
26: }
27: return [];
28: });
29: }
30: public function columns(): array
31: {
32: return [
33: Column::make(__('messages.appointment.patient'),
34: 'user.first_name')->view('transactions.doctor_panel.components.patient')
35: ->sortable()
36: ->searchable(
37: function (Builder $query, $direction) {
38: return $query->whereHas('user', function (Builder $q) use ($direction) {
39: $q->whereRaw("TRIM(CONCAT(first_name,' ',last_name,' ')) like '%{$direction}%'");
40: });
41: }
42: ),
43: Column::make(__('messages.patient.name'), 'user.email')
44: ->hideIf('user.email')
45: ->searchable(),
46: Column::make(__('messages.appointment.date'),
47: 'created_at')->view('transactions.doctor_panel.components.date')
48: ->sortable(),
49: Column::make(__('messages.appointment.payment_method'),
50: 'type')->view('transactions.doctor_panel.components.payment_method')
51: ->sortable()->searchable(),
52: Column::make(__('messages.appointment.appointment_status'), 'id')
53: ->format(function ($value, $row) {
54: return view('transactions.components.appointment_status')
55: ->with([
56: 'row' => $row,
57: 'book' => Appointment::BOOKED,
58: 'checkIn' => Appointment::CHECK_IN,
59: 'checkOut' => Appointment::CHECK_OUT,
60: 'cancel' => Appointment::CANCELLED,
61: ]);
62: }),
63: Column::make(__('messages.doctor_appointment.amount'),
64: 'amount')->view('transactions.doctor_panel.components.amount')
65: ->sortable()->searchable(),
66: Column::make(__('messages.common.action'),
67: 'id')->view('transactions.doctor_panel.components.action'),
68: ];
69: }
70: public function builder(): Builder
71: {
72: $transaction = Transaction::whereHas('doctorappointment')
73: ->with(['doctorappointment', 'user.patient',
'appointment'])->select('transactions.*');
74: return $transaction;
75: }
76: }
[Http > Livewire > DoctorTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Doctor;
4: use App\Models\User;
5: use Illuminate\Database\Eloquent\Builder;
6: use Rappasoft\LaravelLivewireTables\Views\Column;
7: class DoctorTable extends LivewireTableComponent
8: {
9: protected $model = Doctor::class;
10: public bool $showButtonOnHeader = true;
11: public string $buttonComponent = 'doctors.components.add_button';
12: public bool $showFilterOnHeader = true;
13: public array $FilterComponent = ['doctors.components.status_filter', User::STATUS];
14: protected $listeners = ['refresh' => '$refresh', 'resetPage', 'changeStatusFilter'];
15: public string $statusFilter = '';
16: public function configure(): void
17: {
18: $this->setPrimaryKey('id')
19: ->setDefaultSort('created_at', 'desc')
20: ->setQueryStringStatus(false);
21: $this->setThAttributes(function (Column $column) {
22: if ($column->isField('id')) {
23: return [
24: 'class' => 'text-center',
25: ];
26: }
27: return [];
28: });
29: }
30: public function builder(): Builder
31: {
32: $query = Doctor::with(['user', 'specializations', 'reviews'])->select('doctors.*');
33: $query->when($this->statusFilter != '' && $this->statusFilter != User::ALL,
34: function (Builder $query) {
35: return $query->whereHas('user', function (Builder $q) {
36: $q->where('status', $this->statusFilter);
37: });
38: });
39: return $query;
40: }
41: public function columns(): array
42: {
43: return [
44: Column::make(__('messages.doctor.doctor'),
45: 'user.first_name')->view('doctors.components.doctor_name')
46: ->sortable()
47: ->searchable(
48: function (Builder $query, $direction) {
49: return $query->whereHas('user', function (Builder $q) use ($direction) {
50: $q->whereRaw("TRIM(CONCAT(first_name,' ',last_name,' ')) like '%{$direction}%'");
51: });
52: }
53: ),
54: Column::make(__('messages.visit.doctor'), 'user.email')
55: ->hideIf('user.email')
56: ->searchable(),
57: Column::make(__('messages.doctor.status'),
58: 'user.status')->view('doctors.components.status')->sortable(),
59: Column::make(__('messages.common.email_verified'),
60: 'user.email_verified_at')->view('doctors.components.email_verified')
61: ->sortable(),
62: Column::make(__('messages.common.impersonate'),
63: 'user.status')->view('doctors.components.impersonate'),
64: Column::make(__('messages.patient.registered_on'),
65: 'created_at')->view('doctors.components.registered_on')->sortable(),
66: Column::make(__('messages.common.action'), 'id')->view('doctors.components.action'),
67: ];
68: }
69: public function changeStatusFilter($value): void
70: {
71: $this->statusFilter = $value;
72: $this->setBuilder($this->builder());
73: }
74: }
[Http > Livewire > DoctorVisitTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Visit;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class DoctorVisitTable extends LivewireTableComponent
7: {
8: protected $model = Visit::class;
9: public bool $showButtonOnHeader = true;
10: public string $buttonComponent = 'visits.doctor_panel.components.add_button';
11: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
12: public function configure(): void
13: {
14: $this->setPrimaryKey('id')
15: ->setDefaultSort('created_at', 'desc')
16: ->setQueryStringStatus(false);
17: $this->setThAttributes(function (Column $column) {
18: if ($column->isField('id')) {
19: return [
20: 'class' => 'text-center',
21: ];
22: }
23: return [];
24: });
25: }
26: /**
27: *df
28: */
29: public function columns(): array
30: {
31: return [
32: Column::make(__('messages.visit.patient'),
33: 'patient.user.first_name')->view('visits.doctor_panel.components.patient')
34: ->sortable()->searchable(
35: function (Builder $query, $direction) {
36: return $query->whereHas('patient.user', function (Builder $q) use ($direction) {
37: $q->whereRaw("TRIM(CONCAT(first_name,' ',last_name,' ')) like '%{$direction}%'");
38: });
39: }
40: ),
41: Column::make(__('messages.visit.doctor'), 'patient.user.email')
42: ->hideIf('patient.user.email')
43: ->searchable(),
44: Column::make(__('messages.visit.visit_date'),
45: 'visit_date')->view('visits.doctor_panel.components.visit_date')
46: ->sortable(),
47: Column::make(__('messages.common.action'),
48: 'id')->view('visits.doctor_panel.components.action'),
49: ];
50: }
51: public function builder(): Builder
52: {
53: return Visit::with(['patient.user', 'doctor.reviews'])->where('doctor_id',
54: getLoginUser()->doctor->id)
55: ->select('visits.*');
56: }
57: }
[Http > Livewire > EnquiryTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Enquiry;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class EnquiryTable extends LivewireTableComponent
7: {
8: protected $model = Enquiry::class;
9: public bool $showFilterOnHeader = true;
10: public array $FilterComponent = ['fronts.enquiries.components.filter',
11: Enquiry::VIEW_NAME];
12: protected $listeners = ['refresh' => '$refresh', 'resetPage', 'changeStatusFilter'];
13: public string $statusFilter = '';
14: public function configure(): void
15: {
16: $this->setPrimaryKey('id')
17: ->setDefaultSort('created_at', 'desc')
18: ->setQueryStringStatus(false);
19: $this->setThAttributes(function (Column $column) {
20: if ($column->isField('id')) {
21: return [
22: 'class' => 'text-center',
23: ];
24: }
25: return [];
26: });
27: }
28: public function builder(): Builder
29: {
30: $query = Enquiry::query();
31: $query->when($this->statusFilter !== '' && $this->statusFilter != Enquiry::ALL,
32: function (Builder $query) {
33: return $query->where('view', $this->statusFilter);
34: });
35: return $query;
36: }
37: public function columns(): array
38: {
39: return [
40: Column::make(__('messages.common.name'),
'name')->view('fronts.enquiries.components.name')
41: ->sortable()->searchable(),
42: Column::make(__('messages.web.message'),
43: 'message')->view('fronts.enquiries.components.message')
44: ->sortable()->searchable(),
45: Column::make(__('messages.web.status'),
46: 'view')->view('fronts.enquiries.components.status')
47: ->sortable()->searchable(),
48: Column::make(__('messages.doctor.created_at'),
49: 'created_at')->view('fronts.enquiries.components.created_at')
50: ->sortable()->searchable(),
51: Column::make(__('messages.common.action'),
52: 'id')->view('fronts.enquiries.components.action'),
53: ];
54: }
55: public function changeStatusFilter($value): void
56: {
57: $this->statusFilter = $value;
58: $this->setBuilder($this->builder());
59: }
60: }
[Http > Livewire > FaqTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Faq;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class FaqTable extends LivewireTableComponent
7: {
8: protected $model = Faq::class;
9: public bool $showButtonOnHeader = true;
10: public string $buttonComponent = 'fronts.faqs.components.add_button';
11: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
12: public function configure(): void
13: {
14: $this->setPrimaryKey('id')
15: ->setDefaultSort('created_at', 'desc')
16: ->setQueryStringStatus(false);
17: }
18: public function builder(): Builder
19: {
20: return Faq::query();
21: }
22: public function columns(): array
23: {
24: return [
25: Column::make(__('messages.faq.question'),
26: 'question')->view('fronts.faqs.components.question')
27: ->sortable()->searchable(),
28: Column::make(__('messages.faq.answer'),
'answer')->view('fronts.faqs.components.answer')
29: ->sortable()->searchable(),
30: Column::make(__('messages.common.action'),
'id')->view('fronts.faqs.components.action'),
31: ];
32: }
33: }
[Http > Livewire > FrontPatientTestimonialTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\FrontPatientTestimonial;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class FrontPatientTestimonialTable extends LivewireTableComponent
7: {
8: protected $model = FrontPatientTestimonial::class;
9: public bool $showButtonOnHeader = true;
10: public string $buttonComponent =
11: 'fronts.front_patient_testimonials.components.add_button';
12: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
13: public function configure(): void
14: {
15: $this->setPrimaryKey('id')
16: ->setDefaultSort('created_at', 'desc')
17: ->setQueryStringStatus(false);
18: $this->setThAttributes(function (Column $column) {
19: if ($column->isField('id')) {
20: return [
21: 'class' => 'text-center',
22: ];
23: }
24: return [];
25: });
26: }
27: public function builder(): Builder
28: {
29: return FrontPatientTestimonial::with('media');
30: }
31: public function columns(): array
32: {
33: return [
34: Column::make(__('messages.common.name'),
35: 'name')->view('fronts.front_patient_testimonials.components.name')
36: ->sortable()->searchable(),
37: Column::make(__('messages.front_patient_testimonial.short_description'),
38:
39: 'short_description')->view('fronts.front_patient_testimonials.components.short_descri
ption')
40: ->sortable()->searchable(),
41: Column::make(__('messages.common.action'),
42: 'id')->view('fronts.front_patient_testimonials.components.action'),
43: ];
44: }
45: }
[Http > Livewire > GeneratePatientSmartCardsTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use Rappasoft\LaravelLivewireTables\DataTableComponent;
4: use Rappasoft\LaravelLivewireTables\Views\Column;
5: use Illuminate\Database\Eloquent\Builder;
6: use App\Models\Patient;
7: use Illuminate\Support\Carbon;
8: class GeneratePatientSmartCardsTable extends LivewireTableComponent
9: {
10: protected $model = Patient::class;
11: public bool $showButtonOnHeader = true;
12: public string $buttonComponent =
'generate_patient_smart_cards.components.add_button';
13: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
14: public function configure(): void
15: {
16: $this->setPrimaryKey('id');
17: $this->setDefaultSort('patients.created_at', 'desc');
18: $this->setThAttributes(function (Column $column) {
19: if ($column->isField('id')) {
20: return [
21: 'class' => 'text-center',
22: ];
23: }
24: return [];
25: });
26: }
27: public function builder(): Builder
28: {
29: if (isRole('patient')) {
30: $query =
31: Patient::whereHas('smartPatientCard')->where('user_id',auth()->user()->id)->with(['us
er'])->select('*');
32: }else{
33: $query = Patient::whereNot('template_id')->with(['user'])->select('*');
34: }
35: return $query;
36: }
37: public function columns(): array
38: {
39: return [
40: Column::make(__('messages.web.name'),
'user.first_name')->view('patients.components.name')
41: ->sortable()
42: ->searchable(
43: function (Builder $query, $direction) {
44: return $query->whereHas('user', function (Builder $q) use ($direction) {
45: $q->whereRaw("TRIM(CONCAT(first_name,' ',last_name,' ')) like '%{$direction}%'");
46: });
47: }
48: ),
49: Column::make(__('messages.patient.patient_unique_id'), "patient_unique_id")
50: ->sortable(),
51: Column::make(__('messages.smart_patient_card.templat_name'),
52: "smartPatientCard.template_name")
53: ->sortable(),
54: Column::make(__('messages.common.action'),
55: 'id')->view('generate_patient_smart_cards.components.action'),
56: ];
57: }
58: }
[Http > Livewire > HolidayTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Doctor;
4: use App\Models\DoctorHoliday;
5: use Carbon\Carbon;
6: use Illuminate\Database\Eloquent\Builder;
7: use Rappasoft\LaravelLivewireTables\Views\Column;
8: class HolidayTable extends LivewireTableComponent
9: {
10: protected $model = DoctorHoliday::class;
11: public bool $showButtonOnHeader = true;
12: public string $buttonComponent = 'holiday.add_button';
13: public bool $showFilterOnHeader = true;
14: public array $FilterComponent = ['holiday.components.filter', []];
15: protected $listeners = ['refresh' => '$refresh', 'resetPage', 'changeDateFilter'];
16: public string $dateFilter = '';
17: public function configure(): void
18: {
19: $this->setPrimaryKey('id')
20: ->setDefaultSort('created_at', 'desc')
21: ->setQueryStringStatus(false);
22: $this->setThAttributes(function (Column $column) {
23: if ($column->isField('name')) {
24: return [
25: 'class' => 'w-75',
26: ];
27: }
28: return [];
29: });
30: }
31: public function columns(): array
32: {
33: return [
34: Column::make(__('messages.web.reason'), 'name')->view('holiday.components.reason')
35: ->sortable()->searchable(),
36: Column::make(__('messages.appointment.date'),
'date')->view('holiday.components.date')
37: ->sortable(),
38: Column::make(__('messages.common.action'), 'id')->view('holiday.components.action'),
39: ];
40: }
41: public function changeDateFilter($date)
42: {
43: $this->dateFilter = $date;
44: $this->setBuilder($this->builder());
45: }
46: public function builder(): Builder
47: {
48: $doctor = Doctor::whereUserId(getLogInUserId())->first('id');
49: $doctorId = $doctor['id'];
50: $query = DoctorHoliday::whereDoctorId($doctorId);
51: // if ($this->dateFilter != '' && $this->dateFilter != getWeekDate()) {
52: // $timeEntryDate = explode(' - ', $this->dateFilter);
53: // $startDate = Carbon::parse($timeEntryDate[0])->format('Y-m-d');
54: // $endDate = Carbon::parse($timeEntryDate[1])->format('Y-m-d');
55: // $query->whereBetween('date', [$startDate, $endDate]);
56: // } else {
57: // $timeEntryDate = explode(' - ', getWeekDate());
58: // $startDate = Carbon::parse($timeEntryDate[0])->format('Y-m-d');
59: // $endDate = Carbon::parse($timeEntryDate[1])->format('Y-m-d');
60: // $query->whereBetween('date', [$startDate, $endDate]);
61: // }
62: return $query;
63: }
64: }
[Http > Livewire > LiveConsultationsTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\LiveConsultation;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class LiveConsultationsTable extends LivewireTableComponent
7: {
8: protected $model = LiveConsultation::class;
9: public bool $showButtonOnHeader = true;
10: public string $buttonComponent = 'live_consultations.add_button';
11: public bool $showFilterOnHeader = true;
12: public array $FilterComponent = ['live_consultations.components.filter',
13: LiveConsultation::status];
14: protected $listeners = ['refresh' => '$refresh', 'resetPage', 'changeStatusFilter'];
15: public string $statusFilter = '';
16: public function configure(): void
17: {
18: $this->setPrimaryKey('id')
19: ->setDefaultSort('created_at', 'desc')
20: ->setQueryStringStatus(false);
21: $this->setThAttributes(function (Column $column) {
22: if ($column->isField('id')) {
23: return [
24: 'class' => 'text-center',
25: ];
26: }
27: if ($column->isField('status')) {
28: return [
29: 'class' => 'text-center',
30: ];
31: }
32: return [];
33: });
34: }
35: public function columns(): array
36: {
37: return [
38: Column::make(__('messages.live_consultation.consultation_title'),
39: 'consultation_title')->view('live_consultations.components.title')
40: ->sortable()->searchable(),
41: Column::make(__('messages.appointment.date'),
42: 'consultation_date')->view('live_consultations.components.consultation_date')
43: ->sortable(),
44: Column::make(__('messages.live_consultation.created_by'),
45: 'user.first_name')->view('live_consultations.components.created_by')
46: ->sortable(function (Builder $query, $direction) {
47: return $query->orderBy(User::select('first_name')->whereColumn('users.id',
'created_by'),
48: $direction);
49: })->searchable(),
50: Column::make(__('messages.live_consultation.created_for'),
51: 'doctor.user.first_name')->view('live_consultations.components.doctor'),
52: Column::make(__('messages.appointment.patient'),
53: 'patient_id')->view('live_consultations.components.patient'),
54: Column::make(__('messages.doctor.status'),
55: 'status')->view('live_consultations.components.status'),
56: Column::make(__('messages.patient.password'),
57: 'password')->view('live_consultations.components.password')
58: ->sortable()->searchable(),
59: Column::make(__('messages.common.action'),
60: 'id')->view('live_consultations.components.action'),
61: ];
62: }
63: public function changeStatusFilter($value)
64: {
65: $this->statusFilter = $value;
66: $this->setBuilder($this->builder());
67: }
68: public function builder(): Builder
69: {
70: $query = LiveConsultation::with('patient.user', 'doctor.user',
71: 'user')->select('live_consultations.*');
72: $query->when($this->statusFilter !== '' && $this->statusFilter !=
LiveConsultation::ALL,
73: function (Builder $query) {
74: $query->where('live_consultations.status', $this->statusFilter);
75: });
76: if (getLogInUser()->hasRole('patient')) {
77: $query->where('live_consultations.patient_id',
78: getLoginUser()->patient->id)->select('live_consultations.*');
79: }
80: if (getLogInUser()->hasRole('doctor')) {
81: $query->where('live_consultations.doctor_id',
82: getLoginUser()->doctor->id)->select('live_consultations.*');
83: }
84: return $query;
85: }
86: }
[Http > Livewire > LivewireTableComponent.php]
1: <?php
2: namespace App\Http\Livewire;
3: use Rappasoft\LaravelLivewireTables\DataTableComponent;
4: use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
5: /**
6: * Class LivewireTableComponent
7: */
8: class LivewireTableComponent extends DataTableComponent
9: {
10: protected bool $columnSelectStatus = false;
11: public bool $showFilterOnHeader = false;
12: public bool $paginationIsEnabled = false;
13: public bool $paginationStatus = true;
14: public bool $sortingPillsStatus = false;
15: protected $listeners = ['refresh' => '$refresh'];
16: public string $emptyMessage = 'No data available in table';
17: // for table header button
18: public bool $showButtonOnHeader = false;
19: public string $buttonComponent = '';
20: public function configure(): void
21: {
22: // TODO: Implement configure() method.
23: }
24: public function columns(): array
25: {
26: // TODO: Implement columns() method.
27: }
28: /**
29: * @throws DataTableConfigurationException
30: */
31: public function mountWithPagination(): void
32: {
33: if ($this->getPerPage()) {
34: $this->getPerPageAccepted()[] = -1;
35: }
36: $this->setPerPage($this->getPerPageAccepted()[0] ?? 10);
37: }
38: public function resetPage($pageName = 'page'): void
39: {
40: $rowsPropertyData = $this->getRows()->toArray();
41: if ($this->searchStatus) {
42: $prevPageNum = 0;
43: } else {
44: $prevPageNum = $rowsPropertyData['current_page'] - 1;
45: }
46: $prevPageNum = $prevPageNum > 0 ? $prevPageNum : 1;
47: $pageNum = count($rowsPropertyData['data']) > 0 ? $rowsPropertyData['current_page'] :
48: $prevPageNum;
49: $this->setPage($pageNum, $pageName);
50: }
51: }
[Http > Livewire > MedicineBillTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\User;
4: use App\Models\MedicineBill;
5: use Illuminate\Database\Eloquent\Builder;
6: use Rappasoft\LaravelLivewireTables\Views\Column;
7: class MedicineBillTable extends LivewireTableComponent
8: {
9: public bool $showButtonOnHeader = true;
10: public string $buttonComponent = 'medicine-bills.add-button';
11: protected $listeners = ['refresh' => '$refresh', 'changeFilter', 'resetPage'];
12: protected $model = MedicineBill::class;
13: public function configure(): void
14: {
15: $this->setPrimaryKey('id')
16: ->setDefaultSort('medicine_bills.created_at', 'desc');
17: $this->setThAttributes(function (Column $column) {
18: if ($column->isField('id')) {
19: return [
20: 'class' => 'text-center ml-5',
21: ];
22: }
23: if ($column->isField('net_amount')) {
24: return [
25: 'class' => 'text-end',
26: ];
27: }
28: if ($column->isField('payment_status')) {
29: return [
30: 'class' => 'text-center',
31: ];
32: }
33: return [];
34: });
35: }
36: public function columns(): array
37: {
38: return [
39: Column::make(__('messages.medicine_bills.bill_number'), 'bill_number')
40: ->sortable()
41: ->searchable()
42: ->view('medicine-bills.columns.bill_id'),
43: Column::make(__('messages.appointment.date'), 'created_at')
44: ->sortable()
45: ->searchable()
46: ->view('medicine-bills.columns.bill_date'),
47: Column::make(__('messages.visit.patient'), 'patient_id')->hideIf(1),
48: Column::make(__('messages.visit.patient'), 'patient.patientUser.first_name')
49: ->sortable(function (Builder $query, $direction) {
50: return $query->orderBy(User::select('first_name')->whereColumn('id',
'doctors.user_id'),
51: $direction);
52: })->searchable()->view('medicine-bills.columns.patient'),
53: Column::make(__('messages.doctor.doctor'), 'doctor_id')->hideIf(1),
54: Column::make(__('messages.doctor.doctor'), 'doctor.doctorUser.first_name')
55: ->sortable(function (Builder $query, $direction) {
56: return $query->orderBy(User::select('first_name')->whereColumn('id',
'doctors.user_id'),
57: $direction);
58: })->searchable()->view('medicine-bills.columns.doctor'),
59: Column::make(__('messages.purchase_medicine.discount'), 'discount')
60: ->sortable()
61: ->searchable()
62: ->view('medicine-bills.columns.discount'),
63: Column::make(__('messages.purchase_medicine.net_amount'), 'net_amount')
64: ->sortable()
65: ->searchable()
66: ->view('medicine-bills.columns.amount'),
67: Column::make(__('messages.medicine_bills.payment_status'), 'payment_status')
68: ->sortable()->view('medicine-bills.columns.payment_status'),
69: Column::make(__('messages.common.action'), 'id')
70: ->view('medicine-bills.columns.action'),
71: ];
72: }
73: function builder(): Builder
74: {
75: /** @var MedicineBill $query */
76: return
MedicineBill::with(['patient','doctor.user','doctor.doctorUser','patient.user']);
77: }
78: }
[Http > Livewire > MedicineBrandDetailsTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Medicine;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class MedicineBrandDetailsTable extends LivewireTableComponent
7: {
8: protected $model = Medicine::class;
9: public $brandDetails;
10: protected $listeners = ['refresh' => '$refresh', 'changeFilter', 'resetPage'];
11: public function mount(string $brandDetails): void
12: {
13: $this->brandDetails = $brandDetails;
14: }
15: public function configure(): void
16: {
17: $this->setPrimaryKey('id')
18: ->setQueryStringStatus(false);
19: $this->setThAttributes(function (Column $column) {
20: if ($column->isField('selling_price')) {
21: return [
22: 'class' => 'text-end',
23: 'style' => 'padding-right: 4rem !important',
24: ];
25: }
26: if ($column->isField('buying_price')) {
27: return [
28: 'class' => 'd-flex justify-content-end',
29: 'style' => 'padding-right: 4rem !important',
30: ];
31: }
32: return [];
33: });
34: }
35: public function columns(): array
36: {
37: return [
38: Column::make(__('messages.medicine.category'), 'category.name')
39: ->view('brands.templates.columnsDetails.category')
40: ->searchable()
41: ->sortable(),
42: Column::make(__('messages.medicine.medicine'), 'name')
43: ->searchable()
44: ->sortable(),
45: Column::make(__('messages.medicine.brand'), 'category_id')
46: ->hideIf('category_id'),
47: Column::make(__('messages.medicine.selling_price'), 'selling_price')
48: ->view('brands.templates.columnsDetails.selling')
49: ->searchable()
50: ->sortable(),
51: Column::make(__('messages.medicine.buying_price'), 'buying_price')
52: ->view('brands.templates.columnsDetails.buying')
53: ->searchable()
54: ->sortable(),
55: ];
56: }
57: public function builder(): Builder
58: {
59: /** @var Medicine $query */
60: $query = Medicine::with('category', 'brand')->where('brand_id', $this->brandDetails);
61: return $query;
62: }
63: }
[Http > Livewire > MedicineBrandTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Brand;
4: use Rappasoft\LaravelLivewireTables\Views\Column;
5: class MedicineBrandTable extends LivewireTableComponent
6: {
7: protected $model = Brand::class;
8: public bool $showButtonOnHeader = true;
9: public string $buttonComponent = 'brands.add-button';
10: protected $listeners = ['refresh' => '$refresh', 'changeFilter', 'resetPage'];
11: public function configure(): void
12: {
13: $this->setPrimaryKey('id')
14: ->setDefaultSort('brands.created_at', 'desc')
15: ->setQueryStringStatus(false);
16: $this->setThAttributes(function (Column $column) {
17: if ($column->isField('id')) {
18: return [
19: 'class' => 'd-flex justify-content-center w-75 ps-125 text-center',
20: 'style' => 'width: 85% !important',
21: ];
22: }
23: return [
24: 'class' => 'w-50',
25: ];
26: });
27: }
28: public function columns(): array
29: {
30: return [
31: Column::make(__('messages.medicine.brand'), 'name')
32: ->view('brands.templates.columns.name')
33: ->searchable()
34: ->sortable(),
35: Column::make(__('messages.user.email'), 'email')
36: ->view('brands.templates.columns.email')
37: ->sortable(),
38: Column::make(__('messages.web.phone'), 'phone')
39: ->view('brands.templates.columns.phone')
40: ->sortable(),
41: Column::make(__('messages.common.action'), 'id')->view('brands.action'),
42: ];
43: }
44: }
[Http > Livewire > MedicineCategoryDetailsTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Medicine;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class MedicineCategoryDetailsTable extends LivewireTableComponent
7: {
8: protected $model = Medicine::class;
9: protected $listeners = ['refresh' => '$refresh', 'changeFilter', 'resetPage'];
10: public $categoryDetails;
11: public function mount(string $categoryDetails): void
12: {
13: $this->categoryDetails = $categoryDetails;
14: }
15: public function configure(): void
16: {
17: $this->setPrimaryKey('id')
18: // ->setDefaultSort('created_at', 'desc')
19: ->setQueryStringStatus(false);
20: $this->setThAttributes(function (Column $column) {
21: if ($column->isField('selling_price')) {
22: return [
23: 'class' => 'text-end',
24: 'style' => 'padding-right: 4rem !important',
25: ];
26: }
27: if ($column->isField('buying_price')) {
28: return [
29: 'class' => 'd-flex justify-content-end',
30: 'style' => 'padding-right: 4rem !important',
31: ];
32: }
33: return [];
34: });
35: }
36: public function columns(): array
37: {
38: return [
39: Column::make(__('messages.medicine.medicine'), 'name')
40: ->sortable()
41: ->searchable(),
42: Column::make(__('messages.medicine.brand'), 'brand_id')
43: ->hideIf('brand_id'),
44: Column::make(__('messages.medicine.brand'), 'brand.name')
45: ->view('categories.templates.columnsDetails.brand')
46: ->searchable()
47: ->sortable(),
48: Column::make(__('messages.medicine.description'), 'description')
49: ->searchable()
50: ->sortable()
51: ->view('categories.templates.columnsDetails.description'),
52: Column::make(__('messages.medicine.selling_price'), 'selling_price')
53: ->searchable()
54: ->view('categories.templates.columnsDetails.selling_price')
55: ->sortable(),
56: Column::make(__('messages.medicine.buying_price'), 'buying_price')
57: ->searchable()
58: ->view('categories.templates.columnsDetails.buying_price')
59: ->sortable(),
60: ];
61: }
62: public function builder(): Builder
63: {
64: /** @var Medicine $query */
65: $query = Medicine::with('category', 'brand')->where('category_id',
66: $this->categoryDetails);
67: return $query;
68: }
69: }
[Http > Livewire > MedicineCategoryTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Category;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class MedicineCategoryTable extends LivewireTableComponent
7: {
8: protected $model = Category::class;
9: public bool $showButtonOnHeader = true;
10: public bool $showFilterOnHeader = true;
11: public string $buttonComponent = 'categories.add-button';
12: public array $FilterComponent = ['categories.filter-button', Category::STATUS_ARR];
13: protected $listeners = ['refresh' => '$refresh', 'changeFilter', 'resetPage'];
14: public function configure(): void
15: {
16: $this->setPrimaryKey('id')
17: ->setDefaultSort('categories.created_at', 'desc')
18: ->setQueryStringStatus(false);
19: $this->setThAttributes(function (Column $column) {
20: if ($column->isField('id')) {
21: return [
22: 'class' => 'd-flex justify-content-end w-75 ps-125 text-center',
23: 'style' => 'width: 85% !important',
24: ];
25: }
26: return [
27: 'class' => 'w-100',
28: ];
29: });
30: }
31: public function changeFilter($param, $value)
32: {
33: $this->resetPage($this->getComputedPageName());
34: $this->statusFilter = $value;
35: $this->setBuilder($this->builder());
36: }
37: public function columns(): array
38: {
39: return [
40: Column::make(__('messages.common.name'), 'name')
41: ->view('categories.templates.columns.name')
42: ->searchable()
43: ->sortable(),
44: Column::make(__('messages.common.active'), 'is_active')
45: ->view('categories.templates.columns.is_active')
46: ->sortable(),
47: Column::make(__('messages.common.action'), 'id')->view('categories.action'),
48: ];
49: }
50: public function builder(): Builder
51: {
52: /** @var Category $query */
53: $query = Category::query()->select('categories.*');
54: $query->when(isset($this->statusFilter), function (Builder $q) {
55: if ($this->statusFilter == 2) {
56: } else {
57: $q->where('is_active', $this->statusFilter);
58: }
59: });
60: return $query;
61: }
62: public function changeStatus($id)
63: {
64: $category = Category::where('id', $id)->first();
65: if ($category->is_active == Category::ACTIVE) {
66: $category->is_active = Category::INACTIVE;
67: } else {
68: $category->is_active = Category::ACTIVE;
69: }
70: $category->save();
71: $this->dispatchBrowserEvent('success', 'Status updated successfully.');
72: }
73: }
[Http > Livewire > MedicineTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Medicine;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class MedicineTable extends LivewireTableComponent
7: {
8: protected $model = Medicine::class;
9: public bool $showButtonOnHeader = true;
10: public string $buttonComponent = 'medicines.add-button';
11: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
12: public function configure(): void
13: {
14: $this->setPrimaryKey('id')
15: ->setDefaultSort('medicines.created_at', 'desc')
16: ->setQueryStringStatus(false);
17: $this->setTdAttributes(function (Column $column, $row, $columnIndex, $rowIndex) {
18: if ($column->isField('name') || $column->isField('selling_price') ||
19: $column->isField('buying_price')) {
20: return [
21: 'class' => 'pt-5',
22: ];
23: }
24: return [];
25: });
26: $this->setThAttributes(function (Column $column) {
27: if ($column->isField('selling_price') || $column->isField('buying_price')) {
28: return [
29: 'class' => 'text-end',
30: 'style' => 'padding-right: 7rem !important',
31: ];
32: }
33: return [];
34: });
35: }
36: public function columns(): array
37: {
38: return [
39: Column::make(__('messages.medicine.medicine'), 'name')
40: ->view('medicines.templates.columns.name')
41: ->searchable()
42: ->sortable(),
43: Column::make(__('messages.medicine.brand'), 'brand.name')
44: ->searchable()
45: ->sortable(),
46: Column::make(__('messages.medicine.available_quantity'), 'available_quantity')
47: ->view('medicines.templates.columns.avalable_quantity')
48: ->searchable()
49: ->sortable(),
50: Column::make(__('messages.medicine.selling_price'), 'selling_price')
51: ->view('medicines.templates.columns.selling_price')
52: ->searchable()
53: ->sortable(),
54: Column::make(__('messages.medicine.buying_price'), 'buying_price')
55: ->view('medicines.templates.columns.buying_price')
56: ->searchable()
57: ->sortable(),
58: Column::make(__('messages.common.action'), 'id')->view('medicines.action'),
59: ];
60: }
61: public function builder(): Builder
62: {
63: /** @var Medicine $query */
64: return Medicine::with('category', 'brand')->select('medicines.*');
65: }
66: }
[Http > Livewire > PatientAppointmentTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Appointment;
4: use Carbon\Carbon;
5: use Illuminate\Database\Eloquent\Builder;
6: use Rappasoft\LaravelLivewireTables\Views\Column;
7: class PatientAppointmentTable extends LivewireTableComponent
8: {
9: public $doctorId;
10: protected $model = Appointment::class;
11: public bool $showButtonOnHeader = true;
12: public string $buttonComponent = 'patients.appointments.add_button';
13: public bool $showFilterOnHeader = true;
14: public array $FilterComponent = [
15: 'patients.appointments.components.filter', Appointment::PAYMENT_TYPE_ALL,
16: Appointment::STATUS,
17: ];
18: protected $listeners = [
19: 'refresh' => '$refresh', 'resetPage', 'changeStatusFilter', 'changeDateFilter',
20: 'changePaymentTypeFilter',
21: 'changePaymentStatusFilter',
22: ];
23: public int $statusFilter = Appointment::BOOKED;
24: public string $paymentTypeFilter = '';
25: public string $paymentStatusFilter = '';
26: public string $dateFilter = '';
27: public function configure(): void
28: {
29: $this->setPrimaryKey('id')
30: ->setDefaultSort('created_at', 'desc')
31: ->setQueryStringStatus(false);
32: $this->setThAttributes(function (Column $column) {
33: if ($column->isField('id')) {
34: return [
35: 'class' => 'text-center',
36: ];
37: }
38: return [];
39: });
40: }
41: public function builder(): Builder
42: {
43: $query = Appointment::with([
44: 'doctor.user', 'services', 'transaction', 'doctor.reviews',
45: ])->where('patient_id', getLoginUser()->patient->id)->select('appointments.*');
46: $query->when($this->statusFilter != '' && $this->statusFilter !=
Appointment::ALL_STATUS,
47: function (Builder $q) {
48: if ($this->statusFilter != Appointment::ALL) {
49: $q->where('appointments.status', '=', $this->statusFilter);
50: }
51: });
52: $query->when($this->paymentTypeFilter != '' && $this->paymentTypeFilter !=
53: Appointment::ALL_PAYMENT,
54: function (Builder $q) {
55: $q->where('appointments.payment_type', '=', $this->paymentTypeFilter);
56: });
57: $query->when($this->paymentStatusFilter != '',
58: function (Builder $q) {
59: if ($this->paymentStatusFilter != Appointment::ALL_PAYMENT) {
60: if ($this->paymentStatusFilter == Appointment::PENDING) {
61: $q->has('transaction', '=', null);
62: } elseif ($this->paymentStatusFilter == Appointment::PAID) {
63: $q->has('transaction', '!=', null);
64: }
65: }
66: });
67: if ($this->dateFilter != '' && $this->dateFilter != getWeekDate()) {
68: $timeEntryDate = explode(' - ', $this->dateFilter);
69: $startDate = Carbon::parse($timeEntryDate[0])->format('Y-m-d');
70: $endDate = Carbon::parse($timeEntryDate[1])->format('Y-m-d');
71: $query->whereBetween('appointments.date', [$startDate, $endDate]);
72: } else {
73: $timeEntryDate = explode(' - ', getWeekDate());
74: $startDate = Carbon::parse($timeEntryDate[0])->format('Y-m-d');
75: $endDate = Carbon::parse($timeEntryDate[1])->format('Y-m-d');
76: $query->whereBetween('appointments.date', [$startDate, $endDate]);
77: }
78: return $query;
79: }
80: public function changeStatusFilter($status)
81: {
82: $this->statusFilter = $status;
83: $this->setBuilder($this->builder());
84: }
85: public function changePaymentTypeFilter($type)
86: {
87: $this->paymentTypeFilter = $type;
88: $this->setBuilder($this->builder());
89: }
90: public function changeDateFilter($date)
91: {
92: $this->dateFilter = $date;
93: $this->setBuilder($this->builder());
94: }
95: public function columns(): array
96: {
97: return [
98: Column::make(__('messages.doctor.doctor'),
99: 'doctor.user.first_name')->view('patients.appointments.components.doctor')
100: ->sortable()
101: ->searchable(
102: function (Builder $query, $direction) {
103: return $query->whereHas('doctor.user', function (Builder $q) use ($direction) {
104: $q->whereRaw("TRIM(CONCAT(first_name,' ',last_name,' ')) like '%{$direction}%'");
105: });
106: }
107: ),
108: Column::make(__('messages.patient.name'), 'doctor.user.email')
109: ->hideIf('doctor.user.email')
110: ->searchable(),
111: Column::make(__('messages.appointment.appointment_at'),
112: 'date')->view('patients.appointments.components.appointment_at')
113: ->sortable()->searchable(),
114: Column::make(__('messages.appointment.service_charge'),
115: 'services.charges')->view('patients.appointments.components.service_charge')
116: ->sortable()->searchable(),
117: Column::make(__('messages.appointment.payment'), 'payment_type')
118: ->format(function ($value, $row) {
119: return view('patients.appointments.components.payment')
120: ->with([
121: 'row' => $row,
122: 'paid' => Appointment::PAID,
123: 'pending' => Appointment::PENDING,
124: ]);
125: }),
126: Column::make(__('messages.appointment.status'),
127: 'status')->view('patients.appointments.components.status'),
128: Column::make(__('messages.common.action'), 'id')
129: ->format(function ($value, $row) {
130: return view('patients.appointments.components.action')
131: ->with([
132: 'row' => $row,
133: 'checkOut' => Appointment::CHECK_OUT,
134: 'cancel' => Appointment::CANCELLED,
135: ]);
136: }),
137: ];
138: }
139: }
[Http > Livewire > PatientShowPageAppointmentTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Appointment;
4: use Carbon\Carbon;
5: use Illuminate\Database\Eloquent\Builder;
6: use Rappasoft\LaravelLivewireTables\Views\Column;
7: class PatientShowPageAppointmentTable extends LivewireTableComponent
8: {
9: public $patientId;
10: protected $model = Appointment::class;
11: public bool $showFilterOnHeader = true;
12: public array $FilterComponent = ['patients.appointment_filter', Appointment::STATUS];
13: protected $listeners = ['refresh' => '$refresh', 'resetPage', 'changeStatusFilter',
14: 'changeDateFilter'];
15: public int $statusFilter = Appointment::BOOKED;
16: public string $dateFilter = '';
17: public function configure(): void
18: {
19: $this->setPrimaryKey('id')
20: ->setDefaultSort('created_at', 'desc')
21: ->setQueryStringStatus(false);
22: $this->setThAttributes(function (Column $column) {
23: if ($column->isField('id')) {
24: return [
25: 'class' => 'text-center',
26: ];
27: }
28: return [];
29: });
30: }
31: public function builder(): Builder
32: {
33: $query = Appointment::with('doctor')->where('patient_id', '=',
34: $this->patientId)->select('appointments.*');
35: if (getLogInUser()->hasRole('doctor')) {
36: $query = Appointment::with(['doctor.user', 'doctor.reviews'])->where('patient_id',
'=',
37: $this->patientId)->whereDoctorId(getLogInUser()->doctor->id)->select('appointments.*'
);
38: }
39: $query->when($this->statusFilter != '' && $this->statusFilter !=
Appointment::ALL_STATUS,
40: function (Builder $q) {
41: if ($this->statusFilter != Appointment::ALL) {
42: $q->where('appointments.status', '=', $this->statusFilter);
43: }
44: });
45: if ($this->dateFilter != '' && $this->dateFilter != getWeekDate()) {
46: $timeEntryDate = explode(' - ', $this->dateFilter);
47: $startDate = Carbon::parse($timeEntryDate[0])->format('Y-m-d');
48: $endDate = Carbon::parse($timeEntryDate[1])->format('Y-m-d');
49: $query->whereBetween('appointments.date', [$startDate, $endDate]);
50: } else {
51: $timeEntryDate = explode(' - ', getWeekDate());
52: $startDate = Carbon::parse($timeEntryDate[0])->format('Y-m-d');
53: $endDate = Carbon::parse($timeEntryDate[1])->format('Y-m-d');
54: $query->whereBetween('appointments.date', [$startDate, $endDate]);
55: }
56: return $query;
57: }
58: public function changeStatusFilter($status)
59: {
60: $this->statusFilter = $status;
61: $this->setBuilder($this->builder());
62: }
63: public function changeDateFilter($date)
64: {
65: $this->dateFilter = $date;
66: $this->setBuilder($this->builder());
67: }
68: public function columns(): array
69: {
70: return [
71: Column::make(__('messages.doctor.doctor'),
72: 'doctor.user.first_name')->view('patients.components.doctor')
73: ->sortable()
74: ->searchable(
75: function (Builder $query, $direction) {
76: return $query->whereHas('doctor.user', function (Builder $q) use ($direction) {
77: $q->whereRaw("TRIM(CONCAT(first_name,' ',last_name,' ')) like '%{$direction}%'");
78: });
79: }
80: ),
81: Column::make(__('messages.appointment.appointment_at'),
82: 'date')->view('patients.components.appointment_at')
83: ->sortable()->searchable(),
84: Column::make(__('messages.appointment.status'), 'id')
85: ->format(function ($value, $row) {
86: return view('patients.components.status')
87: ->with([
88: 'row' => $row,
89: 'book' => Appointment::BOOKED,
90: 'checkIn' => Appointment::CHECK_IN,
91: 'checkOut' => Appointment::CHECK_OUT,
92: 'cancel' => Appointment::CANCELLED,
93: ]);
94: }),
95: Column::make(__('messages.common.action'),
96: 'id')->view('patients.components.appointments_action'),
97: ];
98: }
99: }
[Http > Livewire > PatientTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use Carbon\Carbon;
4: use App\Models\Patient;
5: use App\Models\User;
6: use Illuminate\Database\Eloquent\Builder;
7: use Rappasoft\LaravelLivewireTables\Views\Column;
8: class PatientTable extends LivewireTableComponent
9: {
10: protected $model = Patient::class;
11: public bool $showButtonOnHeader = true;
12: public string $buttonComponent = 'patients.components.add_button';
13: public bool $showFilterOnHeader = true;
14: public array $FilterComponent = ['patients.components.filter',
Patient::PATIENT_FILTER];
15: protected $listeners = ['refresh' => '$refresh', 'resetPage',
'patientChangeDateFilter'];
16: public string $dateFilter = '';
17: public function configure(): void
18: {
19: $this->setPrimaryKey('id')
20: ->setDefaultSort('created_at', 'desc')
21: ->setQueryStringStatus(false);
22: $this->setThAttributes(function (Column $column) {
23: if ($column->isField('id')) {
24: return [
25: 'class' => 'text-center',
26: ];
27: }
28: return [];
29: });
30: }
31: public function builder(): Builder
32: {
33: $query = Patient::with(['user', 'appointments'])->withCount('appointments');
34: $query->when(
35: $this->dateFilter != '',
36: function (Builder $q) {
37: $today = Carbon::now();
38: if ($this->dateFilter != Patient::ALL) {
39: if ($this->dateFilter == Patient::TODAY) {
40: $q->whereDate('patients.created_at','>=', $today);
41: $q->whereDate('patients.created_at','<=', $today);
42: }
43: elseif ($this->dateFilter == Patient::WEEK) {
44: $q->whereDate('patients.created_at','>=', $today->startOfWeek());
45: $q->whereDate('patients.created_at','<=', $today->endOfWeek());
46: }
47: elseif ($this->dateFilter == Patient::MONTH) {
48: $q->whereDate('patients.created_at','>=', $today->startOfMonth());
49: $q->whereDate('patients.created_at','<=', $today->endOfMonth());
50: }
51: elseif ($this->dateFilter == Patient::YEAR) {
52: $q->whereDate('patients.created_at','>=', $today->startOfYear());
53: $q->whereDate('patients.created_at','<=', $today->endOfYear());
54: }
55: }
56: }
57: );
58: return $query;
59: }
60: public function columns(): array
61: {
62: return [
63: Column::make(__('messages.patient.name'),
64: 'user.first_name')->view('patients.components.name')
65: ->sortable()
66: ->searchable(
67: function (Builder $query, $direction) {
68: return $query->whereHas('user', function (Builder $q) use ($direction) {
69: $q->whereRaw("TRIM(CONCAT(first_name,' ',last_name,' ')) like '%{$direction}%'");
70: });
71: }
72: ),
73: Column::make(__('messages.patient.name'), 'user.email')
74: ->hideIf('user.email')
75: ->searchable(),
76: Column::make(__('messages.doctor_dashboard.total_appointments'), 'id')
77: ->view('patients.components.total_appointments'),
78: Column::make(__('messages.common.email_verified'), 'user.email_verified_at')
79: ->sortable()
80: ->view('patients.components.email_verified'),
81: Column::make(__('messages.common.impersonate'),
82: 'user.first_name')->view('patients.components.impersonate'),
83: Column::make(__('messages.patient.registered_on'),
84: 'created_at')->view('patients.components.registered_on')
85: ->sortable(),
86: Column::make(__('messages.common.action'),
'user.id')->view('patients.components.action'),
87: ];
88: }
89: public function patientChangeDateFilter($date)
90: {
91: $this->dateFilter = $date;
92: $this->setBuilder($this->builder());
93: }
94: }
[Http > Livewire > PatientTransactionTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Transaction;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class PatientTransactionTable extends LivewireTableComponent
7: {
8: protected $model = Transaction::class;
9: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
10: public function configure(): void
11: {
12: $this->setPrimaryKey('id')
13: ->setDefaultSort('created_at', 'desc')
14: ->setQueryStringStatus(false);
15: $this->setThAttributes(function (Column $column) {
16: if ($column->isField('id')) {
17: return [
18: 'class' => 'text-center',
19: ];
20: }
21: if ($column->isField('amount')) {
22: return [
23: 'class' => 'text-end',
24: ];
25: }
26: return [];
27: });
28: }
29: public function columns(): array
30: {
31: return [
32: Column::make(__('messages.appointment.date'),
33: 'created_at')->view('transactions.patient_panel.components.date')
34: ->sortable()->searchable(),
35: Column::make(__('messages.appointment.payment_method'),
36: 'type')->view('transactions.patient_panel.components.payment_method')
37: ->sortable(),
38: Column::make(__('messages.doctor_appointment.amount'),
39: 'amount')->view('transactions.patient_panel.components.amount')
40: ->sortable()->searchable(),
41: Column::make(__('messages.common.action'),
42: 'id')->view('transactions.patient_panel.components.action'),
43: ];
44: }
45: public function builder(): Builder
46: {
47: return Transaction::where('user_id', '=',
getLogInUserId())->select('transactions.*');
48: }
49: }
[Http > Livewire > PatientVisitTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Visit;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class PatientVisitTable extends LivewireTableComponent
7: {
8: protected $model = Visit::class;
9: protected $listeners = ['resetPage'];
10: public function configure(): void
11: {
12: $this->setPrimaryKey('id')
13: ->setDefaultSort('created_at', 'desc')
14: ->setQueryStringStatus(false);
15: $this->setThAttributes(function (Column $column) {
16: if ($column->isField('id')) {
17: return [
18: 'class' => 'text-center',
19: ];
20: }
21: return [];
22: });
23: }
24: public function columns(): array
25: {
26: return [
27: Column::make(__('messages.visit.doctor'),
28: 'doctor.user.first_name')->view('patient_visits.components.doctor')
29: ->sortable()->searchable(
30: function (Builder $query, $direction) {
31: return $query->whereHas('doctor.user', function (Builder $q) use ($direction) {
32: $q->whereRaw("TRIM(CONCAT(first_name,' ',last_name,' ')) like '%{$direction}%'");
33: });
34: }
35: ),
36: Column::make(__('messages.visit.doctor'), 'doctor.user.email')
37: ->hideIf('doctor.user.email')
38: ->searchable(),
39: Column::make(__('messages.visit.visit_date'),
40: 'visit_date')->view('patient_visits.components.visit')
41: ->sortable(),
42: Column::make(__('messages.common.action'),
43: 'id')->view('patient_visits.components.action'),
44: ];
45: }
46: public function builder(): Builder
47: {
48: return Visit::with('visitDoctor.user', 'visitDoctor.reviews')->where('patient_id',
49: getLoginUser()->patient->id)
50: ->select('visits.*');
51: }
52: }
[Http > Livewire > PrescriptionTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Doctor;
4: use App\Models\Prescription;
5: use Illuminate\Database\Eloquent\Builder;
6: use Rappasoft\LaravelLivewireTables\Views\Column;
7: class PrescriptionTable extends LivewireTableComponent
8: {
9: protected $model = Prescription::class;
10: public bool $showButtonOnHeader = true;
11: public bool $showFilterOnHeader = true;
12: public string $buttonComponent = 'prescriptions.add-button';
13: public $FilterComponent = ['prescriptions.filter-button', Prescription::STATUS_ARR];
14: protected $listeners = ['refresh' => '$refresh', 'changeFilter', 'resetPage'];
15: public $appointMentId = '';
16: public $doctor;
17: public $patient;
18: public function mount($id = null)
19: {
20: $this->appointMentId = $id;
21: $this->doctor = getLogInUser()->hasRole('doctor') ? 1 : 0;
22: $this->patient = getLogInUser()->hasRole('patient') ? 1 : 0;
23: }
24: public function configure(): void
25: {
26: $this->setPrimaryKey('id');
27: $this->setDefaultSort('prescriptions.created_at', 'desc')
28: ->setQueryStringStatus(false);
29: $this->setTdAttributes(function (Column $column, $row, $columnIndex, $rowIndex) {
30: if ($column->isField('status')) {
31: return [
32: 'class' => 'p-5',
33: ];
34: }
35: return [];
36: });
37: }
38: public function changeFilter($param, $value)
39: {
40: $this->resetPage($this->getComputedPageName());
41: $this->statusFilter = $value;
42: $this->setBuilder($this->builder());
43: }
44: public function columns(): array
45: {
46: return [
47: Column::make(__('messages.patients'), 'patient.patientUser.first_name')
48: ->view('prescriptions.columns.patient_name')
49: ->sortable()
50: ->searchable()->hideIf($this->patient),
51: Column::make(__('messages.prescription.patient'), 'patient_id')->hideIf(1),
52: Column::make(__('messages.doctors'), 'doctor.doctorUser.first_name')
53: ->view('prescriptions.columns.doctor_name')
54: ->sortable()
55: ->searchable()->hideIf($this->doctor),
56: Column::make(__('messages.doctor_opd_charge.doctor'), 'doctor_id')->hideIf(1),
57: Column::make(__('messages.prescription.medical_history'), 'medical_history')
58: ->view('prescriptions.columns.medical_history')
59: ->sortable(),
60: Column::make(__('messages.web.status'), 'status')
61: ->view('prescriptions.columns.status'),
62: Column::make(__('messages.common.action'), 'id')
63: ->view('prescriptions.action'),
64: ];
65: }
66: public function builder(): Builder
67: {
68: /** @var Prescription $query */
69: if (! getLoggedinDoctor()) {
70: $query = Prescription::query()->select('prescriptions.*')->with('patient', 'doctor');
71: } else {
72: $doctorId = Doctor::where('user_id', getLogInUserId())->first();
73: $query = Prescription::query()->select('prescriptions.*')->with('patient',
74: 'doctor')->where('doctor_id',
75: $doctorId->id);
76: }
77: $query->when(! empty($this->appointMentId), function (Builder $q) {
78: $q->whereAppointmentId($this->appointMentId);
79: });
80: $query->when(isset($this->statusFilter), function (Builder $q) {
81: if ($this->statusFilter == 2) {
82: } else {
83: $q->where('prescriptions.status', $this->statusFilter);
84: }
85: });
86: return $query;
87: }
88: }
[Http > Livewire > PurchaseMedicineTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\PurchaseMedicine;
4: use Rappasoft\LaravelLivewireTables\Views\Column;
5: class PurchaseMedicineTable extends LivewireTableComponent
6: {
7: protected $model = PurchaseMedicine::class;
8: public bool $showButtonOnHeader = true;
9: public bool $showFilterOnHeader = false;
10: public bool $paginationIsEnabled = true;
11: public string $buttonComponent = 'purchase-medicines.action';
12: protected $listeners = ['refresh' => '$refresh', 'changeFilter', 'resetPage'];
13: public function configure(): void
14: {
15: $this->setQueryStringStatus(false);
16: $this->setDefaultSort('purchase_medicines.created_at', 'desc');
17: $this->setPrimaryKey('id');
18: $this->setThAttributes(function (Column $column) {
19: if ($column->isField('id')) {
20: return [
21: 'class' => 'text-center',
22: ];
23: }
24: return [];
25: });
26: }
27: public function columns(): array
28: {
29: return [
30: Column::make(__('messages.purchase_medicine.purchase_number'), 'purchase_no')
31: ->sortable()->searchable()->view('purchase-medicines.columns.purchase_number'),
32: Column::make(__('messages.purchase_medicine.total'), 'total')
33: ->sortable()->searchable()->view('purchase-medicines.columns.total'),
34: Column::make(__('messages.purchase_medicine.tax'), 'tax')
35: ->sortable()->searchable()->view('purchase-medicines.columns.tax'),
36: Column::make(__('messages.purchase_medicine.discount'), 'discount')
37: ->sortable()->searchable()->view('purchase-medicines.columns.discount'),
38: Column::make(__('messages.purchase_medicine.net_amount'), 'net_amount')
39: ->sortable()->searchable()->view('purchase-medicines.columns.net_amount'),
40: Column::make(__('messages.purchase_medicine.payment_mode'), 'payment_type')
41: ->sortable()->searchable()->view('purchase-medicines.columns.payment_type'),
42: Column::make(__('messages.common.action'),
43: 'id')->view('purchase-medicines.columns.action'),
44: ];
45: }
46: }
[Http > Livewire > QrCodeShowPagePatientAppointmentTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Appointment;
4: use Carbon\Carbon;
5: use Illuminate\Database\Eloquent\Builder;
6: use Rappasoft\LaravelLivewireTables\Views\Column;
7: class QrCodeShowPagePatientAppointmentTable extends LivewireTableComponent
8: {
9: public $patientId;
10: protected $model = Appointment::class;
11: protected $listeners = ['refresh' => '$refresh', 'resetPage', 'changeStatusFilter',
12: 'changeDateFilter'];
13: public function configure(): void
14: {
15: $this->setPrimaryKey('id')
16: ->setDefaultSort('created_at', 'desc')
17: ->setQueryStringStatus(false);
18: }
19: public function builder(): Builder
20: {
21: $query = Appointment::with('doctor')->where('patient_id', '=',
22: $this->patientId)->select('appointments.*');
23: if (getLogInUser()->hasRole('doctor')) {
24: $query = Appointment::with(['doctor.user', 'doctor.reviews'])->where('patient_id',
'=',
25: $this->patientId)->whereDoctorId(getLogInUser()->doctor->id)->select('appointments.*'
);
26: }
27: return $query;
28: }
29: public function columns(): array
30: {
31: return [
32: Column::make(__('messages.doctor.doctor'),
33: 'doctor.user.first_name')->view('patients.components.doctor')
34: ->sortable()
35: ->searchable(
36: function (Builder $query, $direction) {
37: return $query->whereHas('doctor.user', function (Builder $q) use ($direction) {
38: $q->whereRaw("TRIM(CONCAT(first_name,' ',last_name,' ')) like '%{$direction}%'");
39: });
40: }
41: ),
42: Column::make(__('messages.appointment.appointment_at'),
43: 'date')->view('patients.components.appointment_at')
44: ->sortable()->searchable(),
45: Column::make(__('messages.appointment.status'), 'id')
46: ->format(function ($value, $row) {
47: return view('patient_qr_code.components.status')
48: ->with([
49: 'row' => $row,
50: 'book' => Appointment::BOOKED,
51: 'checkIn' => Appointment::CHECK_IN,
52: 'checkOut' => Appointment::CHECK_OUT,
53: 'cancel' => Appointment::CANCELLED,
54: ]);
55: }),
56: ];
57: }
58: }
[Http > Livewire > RoleTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Role;
4: use App\Models\User;
5: use Illuminate\Database\Eloquent\Builder;
6: use Rappasoft\LaravelLivewireTables\Views\Column;
7: class RoleTable extends LivewireTableComponent
8: {
9: protected $model = Role::class;
10: public bool $showButtonOnHeader = true;
11: public string $buttonComponent = 'roles.components.add_button';
12: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
13: public function configure(): void
14: {
15: $this->setPrimaryKey('id')
16: ->setDefaultSort('created_at', 'desc')
17: ->setQueryStringStatus(false);
18: }
19: public function builder(): Builder
20: {
21: return Role::with('permissions')->select('roles.*');
22: }
23: public function columns(): array
24: {
25: return [
26: Column::make(__('messages.common.name'),
'display_name')->view('roles.components.role')
27: ->sortable()
28: ->searchable(),
29: Column::make(__('messages.role.permissions'),
30: 'created_at')->view('roles.components.permission'),
31: Column::make(__('messages.common.action'), 'id')->view('roles.components.action'),
32: ];
33: }
34: }
[Http > Livewire > ServiceCategoryTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\ServiceCategory;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class ServiceCategoryTable extends LivewireTableComponent
7: {
8: protected $model = ServiceCategory::class;
9: public bool $showButtonOnHeader = true;
10: public string $buttonComponent = 'service_categories.components.add_button';
11: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
12: public function configure(): void
13: {
14: $this->setPrimaryKey('id')
15: ->setDefaultSort('created_at', 'desc')
16: ->setQueryStringStatus(false);
17: $this->setThAttributes(function (Column $column) {
18: if ($column->isField('id')) {
19: return [
20: 'class' => 'text-center',
21: ];
22: }
23: return [];
24: });
25: }
26: public function columns(): array
27: {
28: return [
29: Column::make(__('messages.common.name'),
30: 'name')->view('service_categories.components.category_name')
31: ->sortable()->searchable(),
32: Column::make(__('messages.web.total_services'),
33: 'id')->view('service_categories.components.service_count'),
34: Column::make(__('messages.common.action'),
35: 'id')->view('service_categories.components.action'),
36: ];
37: }
38: public function builder(): Builder
39: {
40: return ServiceCategory::with('services')->withCount('services');
41: }
42: }
[Http > Livewire > ServiceTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Service;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class ServiceTable extends LivewireTableComponent
7: {
8: protected $model = Service::class;
9: public bool $showButtonOnHeader = true;
10: public string $buttonComponent = 'services.components.add_button';
11: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
12: public string $statusFilter = '';
13: public function configure(): void
14: {
15: $this->setPrimaryKey('id')
16: ->setDefaultSort('created_at', 'desc')
17: ->setQueryStringStatus(false);
18: $this->setThAttributes(function (Column $column) {
19: if ($column->isField('id')) {
20: return [
21: 'class' => 'text-center',
22: ];
23: }
24: if (in_array($column->getField(), ['charges', 'status'], true)) {
25: return [
26: 'class' => 'text-end',
27: ];
28: }
29: return [];
30: });
31: }
32: public function columns(): array
33: {
34: return [
35: Column::make(__('messages.front_service.icon'),
36: 'category_id')->view('services.components.icon'),
37: Column::make(__('messages.common.name'), 'name')->view('services.components.name')
38: ->searchable()
39: ->sortable(),
40: Column::make(__('messages.service.category'),
41: 'serviceCategory.name')->view('services.components.category')
42: ->sortable()
43: ->searchable(),
44: Column::make(__('messages.appointment.service_charge'),
45: 'charges')->view('services.components.service_charge')
46: ->sortable()->searchable(),
47: Column::make(__('messages.doctor.status'),
48: 'status')->view('services.components.status')->sortable(),
49: Column::make(__('messages.common.action'), 'id')->view('services.components.action'),
50: ];
51: }
52: public function builder(): Builder
53: {
54: $query = Service::with(['serviceCategory', 'media'])->select('services.*');
55: $query->when($this->statusFilter !== '' && $this->statusFilter != Service::ALL,
56: function (Builder $query) {
57: $query->where('status', $this->statusFilter);
58: });
59: return $query;
60: }
61: }
[Http > Livewire > SliderTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Slider;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class SliderTable extends LivewireTableComponent
7: {
8: public bool $showSearch = false;
9: protected $model = Slider::class;
10: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
11: public function configure(): void
12: {
13: $this->setPrimaryKey('id')
14: ->setDefaultSort('created_at', 'desc')
15: ->setQueryStringStatus(false)
16: ->setSearchDisabled();
17: $this->setThAttributes(function (Column $column) {
18: if ($column->isField('id')) {
19: return [
20: 'class' => 'text-center',
21: ];
22: }
23: return [];
24: });
25: }
26: public function builder(): Builder
27: {
28: return Slider::with('media')->latest();
29: }
30: public function columns(): array
31: {
32: return [
33: Column::make(__('messages.slider.image'),
34: 'title')->view('fronts.sliders.components.image'),
35: Column::make(__('messages.slider.title'),
36: 'title')->view('fronts.sliders.components.title'),
37: Column::make(__('messages.slider.short_description'),
38: 'short_description')->view('fronts.sliders.components.short_description'),
39: Column::make(__('messages.common.action'),
40: 'id')->view('fronts.sliders.components.action'),
41: ];
42: }
43: }
[Http > Livewire > SmartPatientCardsTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use Rappasoft\LaravelLivewireTables\DataTableComponent;
4: use Rappasoft\LaravelLivewireTables\Views\Column;
5: use App\Models\SmartPatientCards;
6: class SmartPatientCardsTable extends LivewireTableComponent
7: {
8: protected $model = SmartPatientCards::class;
9: public bool $showButtonOnHeader = true;
10: public string $buttonComponent = 'smart_patient_cards.components.add_button';
11: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
12: public function configure(): void
13: {
14: $this->setPrimaryKey('id');
15: $this->setDefaultSort('created_at', 'desc');
16: $this->setThAttributes(function (Column $column) {
17: if ($column->isField('id')) {
18: return [
19: 'class' => 'text-center',
20: ];
21: }
22: return [];
23: });
24: }
25: public function columns(): array
26: {
27: return [
28: Column::make(__('messages.smart_patient_card.templat_name'), "template_name")
29: ->sortable()
30: ->searchable(),
31: Column::make(__('messages.smart_patient_card.header_color'), "header_color")
32: ->view('smart_patient_cards.components.color_code'),
33: Column::make(__('messages.smart_patient_card.email_show'), "show_email")
34: ->view('smart_patient_cards.components.email_show')
35: ->sortable(),
36: Column::make(__('messages.smart_patient_card.phone_show'), "show_phone")
37: ->view('smart_patient_cards.components.show_phone')
38: ->sortable(),
39: Column::make(__('messages.smart_patient_card.dob_show'), "show_dob")
40: ->view('smart_patient_cards.components.show_dob')
41: ->sortable(),
42: Column::make(__('messages.smart_patient_card.blood_group_show'), "show_blood_group")
43: ->view('smart_patient_cards.components.show_blood_group')
44: ->sortable(),
45: Column::make(__('messages.smart_patient_card.address_show'), "show_address")
46: ->view('smart_patient_cards.components.show_address')
47: ->sortable(),
48: Column::make(__('messages.smart_patient_card.unique_id_show'),
"show_patient_unique_id")
49: ->view('smart_patient_cards.components.show_patient_unique_id')
50: ->sortable(),
51: Column::make(__('messages.common.action'),
52: 'id')->view('smart_patient_cards.components.action'),
53: ];
54: }
55: }
[Http > Livewire > SpecializationTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Specialization;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class SpecializationTable extends LivewireTableComponent
7: {
8: protected $model = Specialization::class;
9: public bool $showButtonOnHeader = true;
10: public string $buttonComponent = 'specializations.components.add_button';
11: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
12: public function configure(): void
13: {
14: $this->setPrimaryKey('id')
15: ->setDefaultSort('created_at', 'desc')
16: ->setQueryStringStatus(false);
17: $this->setThAttributes(function (Column $column) {
18: if ($column->isField('id')) {
19: return [
20: 'class' => 'text-center',
21: ];
22: }
23: return [];
24: });
25: }
26: public function columns(): array
27: {
28: return [
29: Column::make(__('messages.common.name'),
'name')->view('specializations.components.name')
30: ->sortable()
31: ->searchable(),
32: Column::make(__('messages.common.action'),
33: 'id')->view('specializations.components.action'),
34: ];
35: }
36: public function builder(): Builder
37: {
38: return Specialization::query();
39: }
40: }
[Http > Livewire > StaffTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\User;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class StaffTable extends LivewireTableComponent
7: {
8: protected $model = User::class;
9: public bool $showButtonOnHeader = true;
10: public string $buttonComponent = 'staffs.components.add_button';
11: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
12: public function configure(): void
13: {
14: $this->setPrimaryKey('id')
15: ->setDefaultSort('created_at', 'desc')
16: ->setQueryStringStatus(false);
17: $this->setThAttributes(function (Column $column) {
18: if ($column->isField('id')) {
19: return [
20: 'class' => 'text-center',
21: ];
22: }
23: return [];
24: });
25: $this->setTdAttributes(function (Column $column, $row, $columnIndex, $rowIndex) {
26: if ($columnIndex == '4') {
27: return [
28: 'class' => 'text-center',
29: ];
30: }
31: return [];
32: });
33: }
34: public function columns(): array
35: {
36: return [
37: Column::make(__('messages.user.full_name'),
38: 'first_name')->view('staffs.components.staff_name')
39: ->sortable()->searchable(
40: function (Builder $query, $direction) {
41: return $query->whereRaw("TRIM(CONCAT(first_name,' ',last_name,' ')) like
42: '%{$direction}%'");
43: }
44: ),
45: Column::make(__('messages.patient.name'), 'email')
46: ->hideIf('email')
47: ->searchable(),
48: Column::make(__('messages.common.email'), 'email')->hideIf(1),
49: Column::make(__('messages.staff.role'), 'email')->view('staffs.components.role'),
50: Column::make(__('messages.common.email_verified'),
51: 'email_verified_at')->view('staffs.components.email_verified')->sortable(),
52: Column::make(__('messages.common.action'), 'id')->view('staffs.components.action'),
53: ];
54: }
55: public function builder(): Builder
56: {
57: return User::with(['roles'])->where('type', User::STAFF)->where('id', '!=',
58: getLogInUserId())->select('users.*');
59: }
60: }
[Http > Livewire > StateTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\State;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class StateTable extends LivewireTableComponent
7: {
8: protected $model = State::class;
9: public bool $showButtonOnHeader = true;
10: public string $buttonComponent = 'states.components.add_button';
11: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
12: public function configure(): void
13: {
14: $this->setPrimaryKey('id')
15: ->setDefaultSort('created_at', 'desc')
16: ->setQueryStringStatus(false);
17: $this->setThAttributes(function (Column $column) {
18: if ($column->isField('id')) {
19: return [
20: 'class' => 'text-center',
21: ];
22: }
23: return [];
24: });
25: }
26: public function columns(): array
27: {
28: return [
29: Column::make(__('messages.common.name'), 'name')->view('states.components.name')
30: ->sortable()
31: ->searchable(),
32: Column::make(__('messages.state.country'),
33: 'country_id')->view('states.components.country')
34: ->sortable()
35: ->searchable(),
36: Column::make(__('messages.common.action'), 'id')->view('states.components.action'),
37: ];
38: }
39: public function builder(): Builder
40: {
41: return State::with('country')->select('states.*');
42: }
43: }
[Http > Livewire > SubscriberTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Subscribe;
4: use Illuminate\Database\Eloquent\Builder;
5: use Rappasoft\LaravelLivewireTables\Views\Column;
6: class SubscriberTable extends LivewireTableComponent
7: {
8: protected $model = Subscribe::class;
9: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
10: public function configure(): void
11: {
12: $this->setPrimaryKey('id')
13: ->setDefaultSort('created_at', 'desc')
14: ->setQueryStringStatus(false);
15: $this->setThAttributes(function (Column $column) {
16: if ($column->isField('id')) {
17: return [
18: 'class' => 'text-center',
19: ];
20: }
21: return [];
22: });
23: }
24: public function builder(): Builder
25: {
26: return Subscribe::query();
27: }
28: public function columns(): array
29: {
30: return [
31: Column::make(__('messages.user.email'),
32: 'email')->view('fronts.subscribers.components.email')
33: ->sortable()->searchable(),
34: Column::make(__('messages.common.action'),
35: 'id')->view('fronts.subscribers.components.action'),
36: ];
37: }
38: }
[Http > Livewire > TransactionTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Appointment;
4: use App\Models\Transaction;
5: use Illuminate\Database\Eloquent\Builder;
6: use Rappasoft\LaravelLivewireTables\Views\Column;
7: class TransactionTable extends LivewireTableComponent
8: {
9: protected $model = Transaction::class;
10: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
11: public function configure(): void
12: {
13: $this->setPrimaryKey('id')
14: ->setDefaultSort('created_at', 'desc')
15: ->setQueryStringStatus(false);
16: $this->setThAttributes(function (Column $column) {
17: if ($column->isField('id')) {
18: return [
19: 'class' => 'text-center',
20: ];
21: }
22: if ($column->isField('amount')) {
23: return [
24: 'class' => 'text-end',
25: ];
26: }
27: return [];
28: });
29: }
30: public function builder(): Builder
31: {
32: return Transaction::with(['user.patient','appointment'])->select('transactions.*');
33: }
34: public function columns(): array
35: {
36: return [
37: Column::make(__('messages.appointment.patient'),
38: 'user.first_name')->view('transactions.components.patient')
39: ->sortable()
40: ->searchable(
41: function (Builder $query, $direction) {
42: return $query->whereHas('user', function (Builder $q) use ($direction) {
43: $q->whereRaw("TRIM(CONCAT(first_name,' ',last_name,' ')) like '%{$direction}%'");
44: });
45: }
46: ),
47: Column::make(__('messages.patient.name'), 'user.email')
48: ->hideIf('user.email')
49: ->searchable(),
50: Column::make(__('messages.appointment.date'),
51: 'created_at')->view('transactions.components.date')
52: ->sortable(),
53: Column::make(__('messages.appointment.payment_method'),
54: 'type')->view('transactions.components.payment_method'),
55: Column::make(__('messages.appointment.appointment_status'), 'id')
56: ->format(function ($value, $row) {
57: return view('transactions.components.appointment_status')
58: ->with([
59: 'row' => $row,
60: 'book' => Appointment::BOOKED,
61: 'checkIn' => Appointment::CHECK_IN,
62: 'checkOut' => Appointment::CHECK_OUT,
63: 'cancel' => Appointment::CANCELLED,
64: ]);
65: }),
66: Column::make(__('messages.doctor_appointment.amount'),
67: 'amount')->view('transactions.components.amount')
68: ->sortable()->searchable(),
69: Column::make(__('messages.common.action'),
'id')->view('transactions.components.action'),
70: ];
71: }
72: }
[Http > Livewire > UsedMedicineTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\Medicine;
4: use App\Models\MedicineBill;
5: use App\Models\SaleMedicine;
6: use Illuminate\Database\Eloquent\Builder;
7: use Rappasoft\LaravelLivewireTables\Views\Column;
8: class UsedMedicineTable extends LivewireTableComponent
9: {
10: public bool $showFilterOnHeader = false;
11: public bool $showButtonOnHeader = false;
12: protected $model = MedicineBill::class;
13: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
14: public function configure(): void
15: {
16: $this->setPrimaryKey('id')
17: ->setDefaultSort('sale_medicines.created_at', 'desc')
18: ->setQueryStringStatus(false);
19: }
20: public function columns(): array
21: {
22: return [
23: Column::make('Id', 'medicine_bill_id')
24: ->sortable()->hideIf(1),
25: Column::make(__('messages.medicines'), 'medicine_id')
26: ->sortable(function(Builder $query, $direction) {
27: return $query->orderBy(Medicine::select('name')->whereColumn('id',
28: 'sale_medicines.medicine_id'), $direction);
29: })->searchable(
30: function (Builder $query, $direction) {
31: return $query->whereHas('medicine', function (Builder $q) use ($direction) {
32: $q->whereRaw("name like '%{$direction}%'");
33: });
34: }
35: )->view('used-medicine.columns.medicine'),
36: Column::make(__('messages.used_medicine.used_quantity'), 'sale_quantity')
37: ->sortable()->searchable()->view('used-medicine.columns.quantity'),
38: Column::make('Model id', 'medicineBill.model_id')
39: ->sortable()->hideIf(1),
40: Column::make(__('messages.used_medicine.used_at'), 'medicineBill.model_type')
41: ->sortable()->searchable()->view('used-medicine.columns.used_at'),
42: Column::make(__('messages.appointment.date'), 'created_at')
43: ->sortable()->searchable()->view('used-medicine.columns.date'),
44: ];
45: }
46: public function builder(): Builder
47: {
48: return SaleMedicine::with(['medicineBill', 'medicine'])->whereHas('medicineBill',
function
49: (Builder $q) {
50: $q->where('payment_status', true);
51: });
52: }
53: }
[Http > Livewire > VisitTable.php]
1: <?php
2: namespace App\Http\Livewire;
3: use App\Models\User;
4: use App\Models\Visit;
5: use Illuminate\Database\Eloquent\Builder;
6: use Rappasoft\LaravelLivewireTables\Views\Column;
7: class VisitTable extends LivewireTableComponent
8: {
9: protected $model = Visit::class;
10: public bool $showButtonOnHeader = true;
11: public string $buttonComponent = 'visits.components.add_button';
12: protected $listeners = ['refresh' => '$refresh', 'resetPage'];
13: public function configure(): void
14: {
15: $this->setPrimaryKey('id')
16: ->setDefaultSort('created_at', 'desc')
17: ->setQueryStringStatus(false);
18: $this->setThAttributes(function (Column $column) {
19: if ($column->isField('id')) {
20: return [
21: 'class' => 'text-center',
22: ];
23: }
24: return [];
25: });
26: }
27: public function builder(): Builder
28: {
29: return Visit::with(['doctor.user', 'patient.user'])->select('visits.*');
30: }
31: public function columns(): array
32: {
33: return [
34: Column::make(__('messages.visit.doctor'),
35: 'doctor.user.first_name')->view('visits.components.doctor')
36: ->sortable()->searchable(
37: function (Builder $query, $direction) {
38: return $query->whereHas('doctor.user', function (Builder $q) use ($direction) {
39: $q->whereRaw("TRIM(CONCAT(first_name,' ',last_name,' ')) like '%{$direction}%'");
40: });
41: }
42: ),
43: Column::make(__('messages.visit.doctor'), 'doctor.doctorUser.email')
44: ->hideIf('doctor.doctorUser.email')
45: ->searchable(),
46: Column::make(__('messages.visit.patient'), 'patient.patientUser.first_name')
47: ->view('visits.components.patient')
48: ->sortable(function (Builder $query, $direction) {
49: return $query->orderBy(User::select('first_name')->whereColumn('id',
'patients.user_id'),
50: $direction);
51: })
52: ->searchable(),
53: Column::make(__('messages.visit.patient'), 'patient.patientUser.last_name')
54: ->hideIf('patient.patientUser.last_name')
55: ->searchable(),
56: Column::make(__('messages.visit.patient'), 'patient.patientUser.email')
57: ->hideIf('patient.patientUser.email')
58: ->searchable(),
59: Column::make(__('messages.visit.visit_date'),
60: 'visit_date')->view('visits.components.visit_date')
61: ->sortable(),
62: Column::make(__('messages.common.action'), 'id')->view('visits.components.action'),
63: ];
64: }
65: }
[Http > Middleware > Authenticate.php]
1: <?php
2: namespace App\Http\Middleware;
3: use Closure;
4: use Illuminate\Auth\AuthenticationException;
5: use Illuminate\Auth\Middleware\Authenticate as Middleware;
6: use Illuminate\Http\Request;
7: use Illuminate\Support\Facades\App;
8: use Illuminate\Support\Facades\Auth;
9: use Symfony\Component\HttpFoundation\Response;
10: class Authenticate extends Middleware
11: {
12: /**
13: * Handle an incoming request.
14: *
15: * @param string[] ...$guards
16: *
17: * @throws AuthenticationException
18: * @throws AuthenticationException
19: */
20: public function handle($request, Closure $next, ...$guards)
21: {
22: $this->authenticate($request, $guards);
23: App::setLocale(Auth::user()->language);
24: return $next($request);
25: }
26: /**
27: * Get the path the user should be redirected to when they are not authenticated.
28: */
29: protected function redirectTo($request)
30: {
31: if (! $request->expectsJson()) {
32: return route('login');
33: }
34: }
35: }
[Http > Middleware > checkImpersonateUser.php]
1: <?php
2: namespace App\Http\Middleware;
3: use Closure;
4: use Illuminate\Http\Request;
5: use Symfony\Component\HttpFoundation\Response;
6: class checkImpersonateUser
7: {
8: /**
9: * Handle an incoming request.
10: */
11: public function handle(Request $request, Closure $next): Response
12: {
13: if (\Request::route()->getName() == 'impersonate.leave') {
14: getLogInUser()->leaveImpersonation();
15: return redirect()->route('admin.dashboard');
16: }
17: if (session('impersonated_by')) {
18: if (getLogInUser()->hasRole('doctor')) {
19: return redirect()->route('doctors.dashboard');
20: } elseif (getLogInUser()->hasRole('patient')) {
21: return redirect()->route('patients.dashboard');
22: }
23: return redirect()->route('admin.dashboard');
24: }
25: return $next($request);
26: }
27: }
[Http > Middleware > CheckUserStatus.php]
1: <?php
2: namespace App\Http\Middleware;
3: use Closure;
4: use Flash;
5: use Illuminate\Http\Request;
6: use Illuminate\Support\Facades\Auth;
7: use Symfony\Component\HttpFoundation\Response;
8: /**
9: * Class CheckUserStatus
10: */
11: class CheckUserStatus
12: {
13: /**
14: * Handle an incoming request.
15: */
16: public function handle(Request $request, Closure $next): Response
17: {
18: $response = $next($request);
19: if (getSettingValue('email_verified') && ! getLogInUser()->email_verified_at) {
20: Auth::logout();
21: Flash::error('Please verify your email.');
22: return \Redirect::to('login');
23: }
24: if (Auth::check() && ! getLogInUser()->status) {
25: Auth::logout();
26: Flash::error('Your Account is currently disabled, please contact to administrator.');
27: return \Redirect::to('login');
28: }
29: return $response;
30: }
31: }
[Http > Middleware > EncryptCookies.php]
1: <?php
2: namespace App\Http\Middleware;
3: use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
4: class EncryptCookies extends Middleware
5: {
6: /**
7: * The names of the cookies that should not be encrypted.
8: *
9: * @var array
10: */
11: protected $except = [
12: //
13: ];
14: }
[Http > Middleware > PreventRequestsDuringMaintenance.php]
1: <?php
2: namespace App\Http\Middleware;
3: use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as
Middleware;
4: class PreventRequestsDuringMaintenance extends Middleware
5: {
6: /**
7: * The URIs that should be reachable while maintenance mode is enabled.
8: *
9: * @var array
10: */
11: protected $except = [
12: //
13: ];
14: }
[Http > Middleware > RedirectIfAuthenticated.php]
1: <?php
2: namespace App\Http\Middleware;
3: use Closure;
4: use Illuminate\Http\Request;
5: use Illuminate\Support\Facades\Auth;
6: use Illuminate\Support\Facades\Redirect;
7: use Symfony\Component\HttpFoundation\Response;
8: class RedirectIfAuthenticated
9: {
10: /**
11: * Handle an incoming request.
12: */
13: public function handle(Request $request, Closure $next, string ...$guards): Response
14: {
15: $guards = empty($guards) ? [null] : $guards;
16: foreach ($guards as $guard) {
17: if (Auth::guard($guard)->check()) {
18: return Redirect::to(getDashboardURL());
19: }
20: }
21: return $next($request);
22: }
23: }
[Http > Middleware > SetLanguage.php]
1: <?php
2: namespace App\Http\Middleware;
3: use Closure;
4: use Illuminate\Http\Request;
5: use Symfony\Component\HttpFoundation\Response;
6: use App\Models\User;
7: use Illuminate\Support\Facades\Session;
8: use App\Models\Setting;
9: class SetLanguage
10: {
11: /**
12: * use Illuminate\Support\Facades\Session;
13: */
14: public function handle(Request $request, Closure $next): Response
15: {
16: $localeLanguage = Session::get('languageName');
17: $lan = Setting::where('key','language')->get()->toArray()[0];
18: if (! isset($localeLanguage)) {
19: if (isset($localeLanguage)) {
20: \App::setLocale($localeLanguage);
21: }
22: \App::setLocale($lan['value']);
23: Session::put('languageName', $lan['value']);
24: } else {
25: \App::setLocale($localeLanguage);
26: }
27: return $next($request);
28: }
29: }
[Http > Middleware > TrimStrings.php]
1: <?php
2: namespace App\Http\Middleware;
3: use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
4: class TrimStrings extends Middleware
5: {
6: /**
7: * The names of the attributes that should not be trimmed.
8: *
9: * @var array<int, string>
10: */
11: protected $except = [
12: 'current_password',
13: 'password',
14: 'password_confirmation',
15: ];
16: }
[Http > Middleware > TrustHosts.php]
1: <?php
2: namespace App\Http\Middleware;
3: use Illuminate\Http\Middleware\TrustHosts as Middleware;
4: class TrustHosts extends Middleware
5: {
6: /**
7: * Get the host patterns that should be trusted.
8: *
9: * @return array<int, string|null>
10: */
11: public function hosts(): array
12: {
13: return [
14: $this->allSubdomainsOfApplicationUrl(),
15: ];
16: }
17: }
[Http > Middleware > TrustProxies.php]
1: <?php
2: namespace App\Http\Middleware;
3: use Illuminate\Http\Middleware\TrustProxies as Middleware;
4: use Illuminate\Http\Request;
5: class TrustProxies extends Middleware
6: {
7: /**
8: * The trusted proxies for this application.
9: *
10: * @var array<int, string>|string|null
11: */
12: protected $proxies;
13: /**
14: * The headers that should be used to detect proxies.
15: *
16: * @var int
17: */
18: protected $headers =
19: Request::HEADER_X_FORWARDED_FOR |
20: Request::HEADER_X_FORWARDED_HOST |
21: Request::HEADER_X_FORWARDED_PORT |
22: Request::HEADER_X_FORWARDED_PROTO |
23: Request::HEADER_X_FORWARDED_AWS_ELB;
24: }
[Http > Middleware > ValidateSignature.php]
1: <?php
2: namespace App\Http\Middleware;
3: use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
4: class ValidateSignature extends Middleware
5: {
6: /**
7: * The names of the query string parameters that should be ignored.
8: *
9: * @var array<int, string>
10: */
11: protected $except = [
12: // 'fbclid',
13: // 'utm_campaign',
14: // 'utm_content',
15: // 'utm_medium',
16: // 'utm_source',
17: // 'utm_term',
18: ];
19: }
[Http > Middleware > VerifyCsrfToken.php]
1: <?php
2: namespace App\Http\Middleware;
3: use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
4: class VerifyCsrfToken extends Middleware
5: {
6: /**
7: * The URIs that should be excluded from CSRF verification.
8: *
9: * @var array
10: */
11: protected $except = [
12: 'razorpay-payment-success',
13: 'razorpay-payment-failed',
14: 'paytm-callback',
15: ];
16: }
[Http > Middleware > XSS.php]
1: <?php
2: namespace App\Http\Middleware;
3: use Closure;
4: use Illuminate\Http\Request;
5: use Symfony\Component\HttpFoundation\Response;
6: /**
7: * Class XSS
8: */
9: class XSS
10: {
11: public function handle(Request $request, Closure $next): Response
12: {
13: if ($request->route()->getName() == 'cms.update') {
14: return $next($request);
15: }
16: $input = $request->all();
17: array_walk_recursive($input, function (&$input) {
18: $input = (is_null($input)) ? null : strip_tags($input);
19: });
20: $request->merge($input);
21: return $next($request);
22: }
23: }
[Http > Requests > CreateAppointmentRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Appointment;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateAppointmentRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: $rules = Appointment::$rules;
20: return $rules;
21: }
22: /**
23: * @return array|string[]
24: */
25: public function messages(): array
26: {
27: return [
28: 'service_id.required' => __('messages.appointment.ServiceRequired'),
29: 'patient_id.required' => __('messages.appointment.PatientRequired'),
30: 'from_time.required' => __('messages.appointment.SelectAppointment'),
31: ];
32: }
33: }
[Http > Requests > CreateBrandRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Brand;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateBrandRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return Brand::$rules;
20: }
21: }
[Http > Requests > CreateCategoryRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Category;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateCategoryRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return Category::$rules;
20: }
21: }
[Http > Requests > CreateCityRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\City;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateCityRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return City::$rules;
20: }
21: }
[Http > Requests > CreateCountryRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Country;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateCountryRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return Country::$rules;
20: }
21: }
[Http > Requests > CreateCurrencyRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Currency;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateCurrencyRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return Currency::$rules;
20: }
21: }
[Http > Requests > CreateDoctorSessionRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\DoctorSession;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateDoctorSessionRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return DoctorSession::$rules;
20: }
21: }
[Http > Requests > CreateEnquiryRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Enquiry;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateEnquiryRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return Enquiry::$rules;
20: }
21: /**
22: * Get the validation rules that apply to the request.
23: */
24: public function messages(): array
25: {
26: app()->setLocale(checkLanguageSession());
27: return [
28: 'name.required'=> __('messages.common.name_required'),
29: 'email.required'=> __('messages.common.email_required'),
30: 'message.required'=> __('messages.common.message_required'),
31: 'subject.required'=> __('messages.common.subject_required'),
32: 'email.max' => __('messages.common.email_max'),
33: 'email.regex' => __('messages.common.email_regex'),
34: ];
35: }
36: }
[Http > Requests > CreateFaqRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Faq;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateFaqRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return Faq::$rules;
20: }
21: }
[Http > Requests > CreateFrontAppointmentRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Appointment;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateFrontAppointmentRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: $rules = Appointment::$rules;
20: unset($rules['patient_id']);
21: $rules['email'] =
22: 'required|email|max:255|regex:/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[
a-z]{2,6}$/ix';
23: return $rules;
24: }
25: /**
26: * @return array|string[]
27: */
28: public function messages(): array
29: {
30: return [
31: 'service_id.required' => 'Service field is required.',
32: 'from_time.required' => 'Please select appointment time slot.',
33: ];
34: }
35: }
[Http > Requests > CreateFrontPatientTestimonialRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\FrontPatientTestimonial;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateFrontPatientTestimonialRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return FrontPatientTestimonial::$rules;
20: }
21: /**
22: * @return string[]
23: */
24: public function messages(): array
25: {
26: return [
27: 'profile.max' => 'Profile size should be less than 2 MB',
28: ];
29: }
30: }
[Http > Requests > CreateHolidayRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\DoctorHoliday;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateHolidayRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: $rules = DoctorHoliday::$rules;
20: return $rules;
21: }
22: }
[Http > Requests > CreateMedicineBillRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: class CreateMedicineBillRequest extends FormRequest
5: {
6: /**
7: * Determine if the user is authorized to make this request.
8: */
9: public function authorize(): bool
10: {
11: return true;
12: }
13: /**
14: * Get the validation rules that apply to the request.
15: *
16: * @return array<string, mixed>
17: */
18: public function rules(): array
19: {
20: return [
21: 'discount' => 'nullable|numeric',
22: ];
23: }
24: }
[Http > Requests > CreateMedicineRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Medicine;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateMedicineRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: protected function prepareForValidation()
15: {
16: $this->sanitize();
17: }
18: /**
19: * Get the validation rules that apply to the request.
20: */
21: public function rules(): array
22: {
23: return Medicine::$rules;
24: }
25: public function messages(): array
26: {
27: return [
28: 'category_id.required' =>__('messages.common.category_required'),
29: 'brand_id.required' => __('messages.common.brand_required'),
30: ];
31: }
32: public function sanitize()
33: {
34: $input = $this->all();
35: $input['selling_price'] = ! empty($input['selling_price']) ? str_replace(',', '',
36: $input['selling_price']) : null;
37: $input['buying_price'] = ! empty($input['buying_price']) ? str_replace(',', '',
38: $input['buying_price']) : null;
39: $this->replace($input);
40: }
41: }
[Http > Requests > CreatePatientRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Patient;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreatePatientRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return Patient::$rules;
20: }
21: public function messages(): array
22: {
23: return [
24: 'patient_unique_id.regex' => 'Space not allowed in unique id field',
25: 'profile.max' => 'Profile size should be less than 2 MB',
26: ];
27: }
28: }
[Http > Requests > CreatePaytmDetailRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: class CreatePaytmDetailRequest extends FormRequest
5: {
6: /**
7: * Determine if the user is authorized to make this request.
8: */
9: public function authorize(): bool
10: {
11: return true;
12: }
13: /**
14: * Get the validation rules that apply to the request.
15: */
16: public function rules(): array
17: {
18: return [
19: 'name' => 'required',
20: 'email' => 'required|email:filter',
21: 'mobile' => 'required|numeric',
22: ];
23: }
24: /**
25: * @return string[]
26: */
27: public function messages(): array
28: {
29: return [
30: 'mobile.required' => 'Mobile number field is required.',
31: ];
32: }
33: }
[Http > Requests > CreatePrescriptionRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Prescription;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreatePrescriptionRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return Prescription::$rules;
20: }
21: }
[Http > Requests > CreatePurchaseMedicineRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: class CreatePurchaseMedicineRequest extends FormRequest
5: {
6: /**
7: * Determine if the user is authorized to make this request.
8: */
9: public function authorize(): bool
10: {
11: return true;
12: }
13: /**
14: * Get the validation rules that apply to the request.
15: *
16: * @return array<string, mixed>
17: */
18: public function rules(): array
19: {
20: return [];
21: }
22: }
[Http > Requests > CreateQualificationRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Qualification;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateQualificationRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return Qualification::$rules;
20: }
21: /**
22: * @return string[]
23: */
24: public function messages(): array
25: {
26: return [
27: 'degree.required' => __('messages.flash.degree_required'),
28: 'university.required' => __('messages.flash.university_required'),
29: 'year.required' => __('messages.flash.year_required'),
30: ];
31: }
32: }
[Http > Requests > CreateReviewRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Review;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateReviewRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return Review::$rules;
20: }
21: }
[Http > Requests > CreateRoleRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Role;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateRoleRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return Role::$rules;
20: }
21: /**
22: * @return string[]
23: */
24: public function messages(): array
25: {
26: return [
27: 'display_name.required' => __('messages.common.name_required'),
28: 'display_name.unique' => __('messages.common.name_already_taken'),
29: 'permission_id.required' => __('messages.common.any_one_permission'),
30: ];
31: }
32: }
[Http > Requests > CreateServiceCategoryRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\ServiceCategory;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateServiceCategoryRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return ServiceCategory::$rules;
20: }
21: }
[Http > Requests > CreateServicesRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Service;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateServicesRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return Service::$rules;
20: }
21: /**
22: * @return string[]
23: */
24: public function messages(): array
25: {
26: return [
27: 'category_id.required' => __('messages.common.category_required'),
28: ];
29: }
30: }
[Http > Requests > CreateSliderRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Slider;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateSliderRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return Slider::$rules;
20: }
21: }
[Http > Requests > CreateSmartCardTemplateRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: use App\Models\SmartPatientCards;
5: class CreateSmartCardTemplateRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: *
17: * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
18: */
19: public function rules(): array
20: {
21: return SmartPatientCards::$rules;
22: }
23: }
[Http > Requests > CreateSpecializationRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Specialization;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateSpecializationRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return Specialization::$rules;
20: }
21: }
[Http > Requests > CreateStaffRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: class CreateStaffRequest extends FormRequest
5: {
6: /**
7: * Determine if the user is authorized to make this request.
8: */
9: public function authorize(): bool
10: {
11: return true;
12: }
13: /**
14: * Get the validation rules that apply to the request.
15: */
16: public function rules(): array
17: {
18: return [
19: 'first_name' => 'required',
20: 'last_name' => 'required',
21: 'email' => 'required|email:filter|unique:users,email',
22: 'contact' => 'nullable|unique:users,contact',
23: 'password' => 'required|same:password_confirmation|min:6',
24: 'gender' => 'required',
25: 'role' => 'required',
26: 'profile' => 'nullable|mimes:jpeg,jpg,png|max:2000',
27: ];
28: }
29: /**
30: * @return string[]
31: */
32: public function messages(): array
33: {
34: return [
35: 'profile.max' => 'Profile size should be less than 2 MB',
36: ];
37: }
38: }
[Http > Requests > CreateStateRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\State;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateStateRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return State::$rules;
20: }
21: }
[Http > Requests > CreateSubscribeRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Subscribe;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateSubscribeRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return Subscribe::$rules;
20: }
21: /**
22: * Get the validation rules that apply to the request.
23: */
24: public function messages(): array
25: {
26: return [
27: 'email.unique' => __('messages.common.email_already_exist'),
28: ];
29: }
30: }
[Http > Requests > CreateUserRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\User;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateUserRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return User::$rules;
20: }
21: /**
22: * @return string[]
23: */
24: public function messages(): array
25: {
26: return [
27: 'profile.max' => 'Profile size should be less than 2 MB',
28: ];
29: }
30: }
[Http > Requests > CreateVisitPrescriptionRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\VisitPrescription;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateVisitPrescriptionRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return VisitPrescription::$rules;
20: }
21: }
[Http > Requests > CreateVisitRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Visit;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateVisitRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return Visit::$rules;
20: }
21: /**
22: * @return string[]
23: */
24: public function messages(): array
25: {
26: return [
27: 'patient_id.required' => 'The Patient field is required',
28: 'doctor_id.required' => 'The Doctor field is required',
29: ];
30: }
31: }
[Http > Requests > CreateZoomCredentialRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\UserZoomCredential;
4: use Illuminate\Foundation\Http\FormRequest;
5: class CreateZoomCredentialRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: *
17: * @return array<string, mixed>
18: */
19: public function rules(): array
20: {
21: return UserZoomCredential::$rules;
22: }
23: }
[Http > Requests > LiveConsultationRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\LiveConsultation;
4: use Illuminate\Foundation\Http\FormRequest;
5: /**
6: * Class LiveConsultationRequest
7: */
8: class LiveConsultationRequest extends FormRequest
9: {
10: /**
11: * Determine if the user is authorized to make this request.
12: */
13: public function authorize(): bool
14: {
15: return true;
16: }
17: /**
18: * Get the validation rules that apply to the request.
19: */
20: public function rules(): array
21: {
22: return LiveConsultation::$rules;
23: }
24: }
[Http > Requests > UpdateAppointmentRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Appointment;
4: use Illuminate\Foundation\Http\FormRequest;
5: class UpdateAppointmentRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: $rules = Appointment::$rules;
20: return $rules;
21: }
22: /**
23: * @return array|string[]
24: */
25: public function messages(): array
26: {
27: return [
28: 'service_id.required' => 'Service field is required',
29: ];
30: }
31: }
[Http > Requests > UpdateBrandRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Brand;
4: use Illuminate\Foundation\Http\FormRequest;
5: class UpdateBrandRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: $rules = Brand::$rules;
20: $rules['email'] = 'nullable|email|unique:brands,email,'.$this->route('brand')->id;
21: $rules['name'] = 'required|unique:brands,name,'.$this->route('brand')->id;
22: return $rules;
23: }
24: }
[Http > Requests > UpdateCategoryRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Category;
4: use Illuminate\Foundation\Http\FormRequest;
5: class UpdateCategoryRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: $rules = Category::$rules;
20: $rules['name'] = 'required|unique:categories,name,'.$this->route('category')->id;
21: return $rules;
22: }
23: }
[Http > Requests > UpdateChangePasswordRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: class UpdateChangePasswordRequest extends FormRequest
5: {
6: /**
7: * Determine if the user is authorized to make this request.
8: */
9: public function authorize(): bool
10: {
11: return true;
12: }
13: /**
14: * Get the validation rules that apply to the request.
15: */
16: public function rules(): array
17: {
18: return [
19: 'current_password' => 'required|min:6',
20: 'new_password' => 'required|min:6|same:confirm_password',
21: 'confirm_password' => 'required|min:6',
22: ];
23: }
24: }
[Http > Requests > UpdateCityRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: class UpdateCityRequest extends FormRequest
5: {
6: /**
7: * Determine if the user is authorized to make this request.
8: */
9: public function authorize(): bool
10: {
11: return true;
12: }
13: /**
14: * Get the validation rules that apply to the request.
15: */
16: public function rules(): array
17: {
18: $rules['name'] = 'required|unique:cities,name,'.$this->route('city')->id;
19: return $rules;
20: }
21: }
[Http > Requests > UpdateCountryRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: class UpdateCountryRequest extends FormRequest
5: {
6: /**
7: * Determine if the user is authorized to make this request.
8: */
9: public function authorize(): bool
10: {
11: return true;
12: }
13: /**
14: * Get the validation rules that apply to the request.
15: */
16: public function rules(): array
17: {
18: $rules['name'] = 'required|unique:countries,name,'.$this->route('country')->id;
19: return $rules;
20: }
21: }
[Http > Requests > UpdateCurrencyRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: class UpdateCurrencyRequest extends FormRequest
5: {
6: /**
7: * Determine if the user is authorized to make this request.
8: */
9: public function authorize(): bool
10: {
11: return true;
12: }
13: /**
14: * Get the validation rules that apply to the request.
15: */
16: public function rules(): array
17: {
18: $rules['currency_name'] =
19: 'required|unique:currencies,currency_name,'.$this->route('currency')->id;
20: $rules['currency_icon'] = 'required';
21: $rules['currency_code'] = 'required|min:3|max:3';
22: return $rules;
23: }
24: }
[Http > Requests > UpdateDoctorSessionRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\DoctorSession;
4: use Illuminate\Foundation\Http\FormRequest;
5: class UpdateDoctorSessionRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: $rules = DoctorSession::$rules;
20: unset($rules['doctor_id']);
21: return $rules;
22: }
23: }
[Http > Requests > UpdateFaqRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Faq;
4: use Illuminate\Foundation\Http\FormRequest;
5: class UpdateFaqRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: $rules = Faq::$rules;
20: return $rules;
21: }
22: }
[Http > Requests > UpdateFrontCmsRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: class UpdateFrontCmsRequest extends FormRequest
5: {
6: /**
7: * Determine if the user is authorized to make this request.
8: */
9: public function authorize(): bool
10: {
11: return true;
12: }
13: /**
14: * Get the validation rules that apply to the request.
15: */
16: public function rules(): array
17: {
18: return [
19: 'about_image_1' => 'mimes:jpg,jpeg,png',
20: 'about_image_2' => 'mimes:jpg,jpeg,png',
21: 'about_image_3' => 'mimes:jpg,jpeg,png',
22: 'about_title' => 'required',
23: 'about_experience' => 'required|numeric',
24: 'about_short_description' => 'required',
25: 'terms_conditions' => 'required',
26: 'privacy_policy' => 'required',
27: ];
28: }
29: }
[Http > Requests > UpdateFrontPatientTestimonialRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\FrontPatientTestimonial;
4: use Illuminate\Foundation\Http\FormRequest;
5: class UpdateFrontPatientTestimonialRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: $rules = FrontPatientTestimonial::$editRules;
20: return $rules;
21: }
22: /**
23: * @return string[]
24: */
25: public function messages(): array
26: {
27: return [
28: 'profile.max' => 'Profile size should be less than 2 MB',
29: ];
30: }
31: }
[Http > Requests > UpdateMedicineBillRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: class UpdateMedicineBillRequest extends FormRequest
5: {
6: /**
7: * Determine if the user is authorized to make this request.
8: */
9: public function authorize(): bool
10: {
11: return true;
12: }
13: /**
14: * Get the validation rules that apply to the request.
15: *
16: * @return array<string, mixed>
17: */
18: public function rules(): array
19: {
20: return [
21: //
22: ];
23: }
24: }
[Http > Requests > UpdateMedicineRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Medicine;
4: use Illuminate\Foundation\Http\FormRequest;
5: class UpdateMedicineRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: protected function prepareForValidation()
15: {
16: $this->sanitize();
17: }
18: /**
19: * Get the validation rules that apply to the request.
20: */
21: public function rules(): array
22: {
23: $rules = Medicine::$rules;
24: $rules['name'] = 'required|unique:medicines,name,'.$this->route('medicine')->id;
25: return $rules;
26: }
27: public function messages(): array
28: {
29: return [
30: 'category_id.required' =>__('messages.common.category_required'),
31: 'brand_id.required' => __('messages.common.brand_required'),
32: ];
33: }
34: public function sanitize()
35: {
36: $input = $this->all();
37: $input['selling_price'] = ! empty($input['selling_price']) ? str_replace(',', '',
38: $input['selling_price']) : null;
39: $input['buying_price'] = ! empty($input['buying_price']) ? str_replace(',', '',
40: $input['buying_price']) : null;
41: $this->replace($input);
42: }
43: }
[Http > Requests > UpdatePatientRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Patient;
4: use Illuminate\Foundation\Http\FormRequest;
5: class UpdatePatientRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: $rules = Patient::$editRules;
20: $rules['patient_unique_id'] =
21: 'required|regex:/^\S*$/u|unique:patients,patient_unique_id,'.$this->route('patient')-
>id;
22: $rules['email'] =
23: 'required|email:filter|unique:users,email,'.$this->route('patient')->user->id;
24: $rules['contact'] =
'nullable|unique:users,contact,'.$this->route('patient')->user->id;
25: $rules['postal_code'] = 'nullable';
26: $rules['profile'] = 'mimes:jpeg,jpg,png|max:2000';
27: return $rules;
28: }
29: public function messages(): array
30: {
31: return [
32: 'patient_unique_id.regex' => 'Space not allowed in unique id field',
33: 'profile.max' => 'Profile size should be less than 2 MB',
34: ];
35: }
36: }
[Http > Requests > UpdatePrescriptionRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Prescription;
4: use Illuminate\Foundation\Http\FormRequest;
5: class UpdatePrescriptionRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: $rules = Prescription::$rules;
20: return $rules;
21: }
22: }
[Http > Requests > UpdateReviewRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Review;
4: use Illuminate\Foundation\Http\FormRequest;
5: class UpdateReviewRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return Review::$rules;
20: }
21: }
[Http > Requests > UpdateRoleRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Role;
4: use Illuminate\Foundation\Http\FormRequest;
5: class UpdateRoleRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: $rules = Role::$rules;
20: $rules['display_name'] =
'required|unique:roles,display_name,'.$this->route('role')->id;
21: return $rules;
22: }
23: /**
24: * @return string[]
25: */
26: public function messages(): array
27: {
28: return [
29: 'display_name.required' => 'Name field is required',
30: 'display_name.unique' => 'The name has already been taken.',
31: 'permission_id.required' => 'Please select any one permission',
32: ];
33: }
34: }
[Http > Requests > UpdateServiceCategoryRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: class UpdateServiceCategoryRequest extends FormRequest
5: {
6: /**
7: * Determine if the user is authorized to make this request.
8: */
9: public function authorize(): bool
10: {
11: return true;
12: }
13: /**
14: * Get the validation rules that apply to the request.
15: */
16: public function rules(): array
17: {
18: $rules['name'] =
19: 'required|unique:service_categories,name,'.$this->route('service_category')->id;
20: return $rules;
21: }
22: }
[Http > Requests > UpdateServicesRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: class UpdateServicesRequest extends FormRequest
5: {
6: /**
7: * Determine if the user is authorized to make this request.
8: */
9: public function authorize(): bool
10: {
11: return true;
12: }
13: /**
14: * Get the validation rules that apply to the request.
15: */
16: public function rules(): array
17: {
18: $rules['name'] = 'required|unique:services,name,'.$this->route('service')->id;
19: $rules['category_id'] = 'required';
20: $rules['charges'] = 'required|min:0|not_in:0';
21: $rules['doctors'] = 'required';
22: $rules['short_description'] = 'required|max:60';
23: $rules['icon'] = 'nullable|mimes:svg,jpeg,png,jpg';
24: return $rules;
25: }
26: /**
27: * @return string[]
28: */
29: public function messages(): array
30: {
31: return [
32: 'category_id.required' => 'The category field is required.',
33: 'doctors.required' => 'The doctor field is required.',
34: 'short_description.required' => 'The short description field is required.',
35: ];
36: }
37: }
[Http > Requests > UpdateSettingRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: class UpdateSettingRequest extends FormRequest
5: {
6: /**
7: * Determine if the user is authorized to make this request.
8: */
9: public function authorize(): bool
10: {
11: return true;
12: }
13: /**
14: * Get the validation rules that apply to the request.
15: */
16: public function rules(): array
17: {
18: if ($this->request->get('sectionName') == 'contact-information') {
19: return [
20: 'country_id' => 'required',
21: 'state_id' => 'required',
22: 'city_id' => 'required',
23: 'address_one' => 'required',
24: 'address_two' => 'required',
25: 'postal_code' => 'required',
26: ];
27: }
28: if ($this->request->get('sectionName') == 'general') {
29: return [
30: 'email' => 'required|email:filter',
31: 'specialities' => 'required',
32: 'clinic_name' => 'required',
33: 'contact_no' => 'required',
34: 'logo' => 'image|mimes:jpeg,png,jpg',
35: 'favicon' => 'image|mimes:png|dimensions:width=32,height=32',
36: 'language' => 'required',
37: ];
38: }
39: }
40: /**
41: * @return string[]
42: */
43: public function messages(): array
44: {
45: return [
46: 'country_id.required' => 'Country field is required.',
47: 'state_id.required' => 'State field is required.',
48: 'city_id.required' => 'City field is required.',
49: 'address_one.required' => 'Address 1 field is required.',
50: 'address_two.required' => 'Address 2 field is required.',
51: 'logo.dimensions' => 'Logo size should be 90 x 60 pixel',
52: 'favicon.dimensions' => 'Favicon size should be 32 x 32 pixel',
53: ];
54: }
55: }
[Http > Requests > UpdateSliderRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Slider;
4: use Illuminate\Foundation\Http\FormRequest;
5: class UpdateSliderRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return Slider::$editRules;
20: }
21: }
[Http > Requests > UpdateSpecializationRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: class UpdateSpecializationRequest extends FormRequest
5: {
6: /**
7: * Determine if the user is authorized to make this request.
8: */
9: public function authorize(): bool
10: {
11: return true;
12: }
13: /**
14: * Get the validation rules that apply to the request.
15: */
16: public function rules(): array
17: {
18: $rules['name'] =
19: 'required|unique:specializations,name,'.$this->route('specialization')->id;
20: return $rules;
21: }
22: }
[Http > Requests > UpdateStaffRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: class UpdateStaffRequest extends FormRequest
5: {
6: /**
7: * Determine if the user is authorized to make this request.
8: */
9: public function authorize(): bool
10: {
11: return true;
12: }
13: /**
14: * Get the validation rules that apply to the request.
15: */
16: public function rules(): array
17: {
18: return [
19: 'first_name' => 'required',
20: 'last_name' => 'required',
21: 'email' => 'required|email:filter|unique:users,email,'.$this->route('staff')->id,
22: 'contact' => 'nullable|unique:users,contact,'.$this->route('staff')->id,
23: 'password' => 'same:password_confirmation|min:6',
24: 'gender' => 'required',
25: 'role' => 'required',
26: 'profile' => 'nullable|mimes:jpeg,jpg,png|max:2000',
27: ];
28: }
29: /**
30: * @return string[]
31: */
32: public function messages(): array
33: {
34: return [
35: 'profile.max' => 'Profile size should be less than 2 MB',
36: ];
37: }
38: }
[Http > Requests > UpdateStateRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: class UpdateStateRequest extends FormRequest
5: {
6: /**
7: * Determine if the user is authorized to make this request.
8: */
9: public function authorize(): bool
10: {
11: return true;
12: }
13: /**
14: * Get the validation rules that apply to the request.
15: */
16: public function rules(): array
17: {
18: $rules['name'] = 'required|unique:states,name,'.$this->route('state')->id;
19: return $rules;
20: }
21: }
[Http > Requests > UpdateUserProfileRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: use Illuminate\Support\Facades\Auth;
5: class UpdateUserProfileRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: $id = Auth::id();
20: return [
21: 'first_name' => 'required',
22: 'last_name' => 'required',
23: 'time_zone' => 'required',
24: 'email' =>
25: 'required|email|unique:users,email,'.$id.'|regex:/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a
-zA-Z]{2,4}$/i',
26: 'image' => 'nullable|mimes:jpeg,jpg,png|max:2000',
27: 'contact' => 'required',
28: ];
29: }
30: public function messages(): array
31: {
32: return [
33: 'contact.required' => 'Contact number field is required.',
34: 'image.max' => 'Avatar size should be less than 2 MB',
35: ];
36: }
37: }
[Http > Requests > UpdateUserRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use Illuminate\Foundation\Http\FormRequest;
4: class UpdateUserRequest extends FormRequest
5: {
6: /**
7: * Determine if the user is authorized to make this request.
8: */
9: public function authorize(): bool
10: {
11: return true;
12: }
13: /**
14: * Get the validation rules that apply to the request.
15: */
16: public function rules(): array
17: {
18: return [
19: 'first_name' => 'required',
20: 'last_name' => 'required',
21: 'email' =>
22: 'required|email|regex:/(.*)@(.*)\.(.*)/|unique:users,email,'.$this->route('doctor')->
user_id,
23: 'contact' => 'nullable|unique:users,contact,'.$this->route('doctor')->user_id,
24: 'dob' => 'nullable|date',
25: 'experience' => 'nullable|numeric',
26: 'specializations' => 'required',
27: 'gender' => 'required',
28: 'status' => 'nullable',
29: 'postal_code' => 'nullable',
30: 'profile' => 'mimes:jpeg,jpg,png|max:2000',
31: ];
32: }
33: /**
34: * @return string[]
35: */
36: public function messages(): array
37: {
38: return [
39: 'profile.max' => 'Profile size should be less than 2 MB',
40: ];
41: }
42: }
[Http > Requests > UpdateVisitPrescriptionRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\VisitPrescription;
4: use Illuminate\Foundation\Http\FormRequest;
5: class UpdateVisitPrescriptionRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: return VisitPrescription::$rules;
20: }
21: }
[Http > Requests > UpdateVisitRequest.php]
1: <?php
2: namespace App\Http\Requests;
3: use App\Models\Visit;
4: use Illuminate\Foundation\Http\FormRequest;
5: class UpdateVisitRequest extends FormRequest
6: {
7: /**
8: * Determine if the user is authorized to make this request.
9: */
10: public function authorize(): bool
11: {
12: return true;
13: }
14: /**
15: * Get the validation rules that apply to the request.
16: */
17: public function rules(): array
18: {
19: $rules = Visit::$rules;
20: return $rules;
21: }
22: /**
23: * @return string[]
24: */
25: public function messages(): array
26: {
27: return [
28: 'patient_id.required' => 'The Patient field is required',
29: 'doctor_id.required' => 'The Doctor field is required',
30: ];
31: }
32: }
[Requests > Auth > LoginRequest.php]
1: <?php
2: namespace App\Http\Requests\Auth;
3: use Illuminate\Auth\Events\Lockout;
4: use Illuminate\Foundation\Http\FormRequest;
5: use Illuminate\Support\Facades\Auth;
6: use Illuminate\Support\Facades\RateLimiter;
7: use Illuminate\Support\Str;
8: use Illuminate\Validation\ValidationException;
9: class LoginRequest extends FormRequest
10: {
11: /**
12: * Determine if the user is authorized to make this request.
13: */
14: public function authorize(): bool
15: {
16: return true;
17: }
18: /**
19: * Get the validation rules that apply to the request.
20: */
21: public function rules(): array
22: {
23: return [
24: 'email' => 'required|string|email',
25: 'password' => 'required|string',
26: ];
27: }
28: /**
29: * Attempt to authenticate the request's credentials.
30: *
31: *
32: * @throws \Illuminate\Validation\ValidationException
33: */
34: public function authenticate(): void
35: {
36: $this->ensureIsNotRateLimited();
37: if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
38: RateLimiter::hit($this->throttleKey());
39: throw ValidationException::withMessages([
40: 'email' => __('auth.failed'),
41: ]);
42: }
43: RateLimiter::clear($this->throttleKey());
44: }
45: /**
46: * Ensure the login request is not rate limited.
47: *
48: *
49: * @throws \Illuminate\Validation\ValidationException
50: */
51: public function ensureIsNotRateLimited(): void
52: {
53: if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
54: return;
55: }
56: event(new Lockout($this));
57: $seconds = RateLimiter::availableIn($this->throttleKey());
58: throw ValidationException::withMessages([
59: 'email' => trans('auth.throttle', [
60: 'seconds' => $seconds,
61: 'minutes' => ceil($seconds / 60),
62: ]),
63: ]);
64: }
65: /**
66: * Get the rate limiting throttle key for the request.
67: */
68: public function throttleKey(): string
69: {
70: return Str::lower($this->input('email')).'|'.$this->ip();
71: }
72: }
[app > Listeners > HandleCreatedGoogleAppointment.php]
1: <?php
2: namespace App\Listeners;
3: use App\Models\Appointment;
4: use App\Models\AppointmentGoogleCalendar;
5: use App\Models\GoogleCalendarIntegration;
6: use App\Models\UserGoogleAppointment;
7: use App\Repositories\GoogleCalendarRepository;
8: use Illuminate\Http\JsonResponse;
9: use Illuminate\Http\Request;
10: use Illuminate\Support\Facades\App;
11: class HandleCreatedGoogleAppointment
12: {
13: /**
14: * Handle the event.
15: */
16: public function handle(object $event): void
17: {
18: $forPatient = $event->forPatient;
19: $appointmentId = $event->appointmentID;
20: if ($forPatient) {
21: $this->createGoogleEventForPatient($appointmentId);
22: } else {
23: $this->createGoogleEventForDoctor($appointmentId);
24: }
25: }
26: /**
27: * @param Request $request
28: */
29: public function createGoogleEventForPatient($appointmentId)
30: {
31: $appointment = Appointment::with('patient.user',
'doctor.user')->find($appointmentId);
32: $patientGoogleCalendarConnected =
33: GoogleCalendarIntegration::whereUserId($appointment->patient->user->id)
34: ->exists();
35: if ($patientGoogleCalendarConnected) {
36: /** @var GoogleCalendarRepository $repo */
37: $repo = App::make(GoogleCalendarRepository::class);
38: $calendarLists =
AppointmentGoogleCalendar::whereUserId($appointment->patient->user->id)
39: ->pluck('google_calendar_id')->toArray();
40: $fullName = $appointment->doctor->user->full_name;
41: $meta['name'] = 'Appointment with Doctor: '.$fullName;
42: $meta['description'] = 'Appointment with '.$fullName.' For
'.$appointment->services->name;
43: $meta['lists'] = $calendarLists;
44: $accessToken = $repo->getAccessToken($appointment->patient->user);
45: $results = $repo->store($appointment, $accessToken, $meta);
46: foreach ($results as $result) {
47: UserGoogleAppointment::create([
48: 'user_id' => $appointment->patient->user->id,
49: 'appointment_id' => $appointment->id,
50: 'google_calendar_id' => $result['google_calendar_id'],
51: 'google_event_id' => $result['id'],
52: ]);
53: }
54: }
55: return true;
56: }
57: /**
58: * @param Request $request
59: * @return bool|JsonResponse
60: */
61: public function createGoogleEventForDoctor($appointmentId)
62: {
63: $appointment = Appointment::with('patient.user',
'doctor.user')->find($appointmentId);
64: $doctorGoogleCalendarConnected =
65: GoogleCalendarIntegration::whereUserId($appointment->doctor->user->id)
66: ->exists();
67: if ($doctorGoogleCalendarConnected) {
68: /** @var GoogleCalendarRepository $repo */
69: $repo = App::make(GoogleCalendarRepository::class);
70: $calendarLists =
AppointmentGoogleCalendar::whereUserId($appointment->doctor->user->id)
71: ->pluck('google_calendar_id')
72: ->toArray();
73: $fullName = $appointment->patient->user->full_name;
74: $meta['name'] = 'Appointment with Patient: '.$fullName;
75: $meta['description'] = 'Appointment with '.$fullName.' For
'.$appointment->services->name;
76: $meta['lists'] = $calendarLists;
77: $accessToken = $repo->getAccessToken($appointment->doctor->user);
78: $doctorResults = $repo->store($appointment, $accessToken, $meta);
79: foreach ($doctorResults as $result) {
80: UserGoogleAppointment::create([
81: 'user_id' => $appointment->doctor->user->id,
82: 'appointment_id' => $appointment->id,
83: 'google_calendar_id' => $result['google_calendar_id'],
84: 'google_event_id' => $result['id'],
85: ]);
86: }
87: }
88: return true;
89: }
90: }
[app > Listeners >
HandleDeletedAppointmentFromGoogleCalendar.php]
1: <?php
2: namespace App\Listeners;
3: use App\Repositories\GoogleCalendarRepository;
4: class HandleDeletedAppointmentFromGoogleCalendar
5: {
6: /**
7: * Handle the event.
8: */
9: public function handle(object $event): void
10: {
11: /** @var GoogleCalendarRepository $repo */
12: $repo = \App::make(GoogleCalendarRepository::class);
13: $events = $event->events;
14: $repo->destroy($events);
15: }
16: }
[app > Mail > AppointmentBookedMail.php]
1: <?php
2: namespace App\Mail;
3: use Carbon\Carbon;
4: use Illuminate\Bus\Queueable;
5: use Illuminate\Mail\Mailable;
6: use Illuminate\Queue\SerializesModels;
7: use Illuminate\Support\Facades\Crypt;
8: class AppointmentBookedMail extends Mailable
9: {
10: use Queueable, SerializesModels;
11: public $data;
12: /**
13: * Create a new message instance.
14: *
15: * @return void
16: */
17: public function __construct($data)
18: {
19: $this->data = $data;
20: }
21: /**
22: * Build the message.
23: */
24: public function build(): static
25: {
26: $email = $this->data['email'];
27: $password = $this->data['original_password'] ?? null;
28: $patientId = $this->data['patient_id'];
29: $appointmentUniqueId = Crypt::encryptString($this->data['appointment_unique_id']);
30: $name = $this->data['first_name'].' '.$this->data['last_name'];
31: $time = $this->data['original_from_time'].' - '.$this->data['original_to_time'];
32: $date = Carbon::createFromFormat('Y-m-d', $this->data['date'])->format('dS,M Y');
33: $subject = 'Appointment Booked SuccessFully';
34: return $this->view('emails.appointment_booked_mail',
35: compact('email', 'password', 'name', 'time', 'date', 'patientId',
'appointmentUniqueId'))
36: ->markdown('emails.appointment_booked_mail')
37: ->subject($subject);
38: }
39: }
[app > Mail > DoctorAppointmentBookMail.php]
1: <?php
2: namespace App\Mail;
3: use Carbon\Carbon;
4: use Illuminate\Bus\Queueable;
5: use Illuminate\Mail\Mailable;
6: use Illuminate\Queue\SerializesModels;
7: class DoctorAppointmentBookMail extends Mailable
8: {
9: use Queueable, SerializesModels;
10: public $data;
11: /**
12: * Create a new message instance.
13: *
14: * @return void
15: */
16: public function __construct($data)
17: {
18: $this->data = $data;
19: }
20: /**
21: * Build the message.
22: */
23: public function build(): static
24: {
25: $name = $this->data['doctor_name'];
26: $patientName = $this->data['patient_name'];
27: $service = $this->data['service'];
28: $time = $this->data['original_from_time'].' - '.$this->data['original_to_time'];
29: $date = Carbon::createFromFormat('Y-m-d', $this->data['date'])->format('dS,M Y');
30: $subject = 'Appointment Booked Successfully';
31: return $this->view('emails.doctor_appointment_booked_mail',
32: compact('name', 'time', 'date', 'patientName', 'service'))
33: ->markdown('emails.doctor_appointment_booked_mail')
34: ->subject($subject);
35: }
36: }
[app > Mail > EnquiryMails.php]
1: <?php
2: namespace App\Mail;
3: use Illuminate\Bus\Queueable;
4: use Illuminate\Mail\Mailable;
5: use Illuminate\Queue\SerializesModels;
6: class EnquiryMails extends Mailable
7: {
8: use Queueable, SerializesModels;
9: public $data;
10: /**
11: * Create a new message instance.
12: *
13: * @return void
14: */
15: public function __construct(string $view, string $subject, array $data = [])
16: {
17: $this->data = $data;
18: $this->view = $view;
19: $this->subject = $subject;
20: }
21: /**
22: * Build the message.
23: */
24: public function build(): static
25: {
26: $mail = $this->subject($this->subject)
27: ->markdown($this->view)
28: ->with($this->data);
29: return $mail;
30: }
31: }
[app > Mail > PatientAppointmentBookMail.php]
1: <?php
2: namespace App\Mail;
3: use Carbon\Carbon;
4: use Illuminate\Bus\Queueable;
5: use Illuminate\Mail\Mailable;
6: use Illuminate\Queue\SerializesModels;
7: use Illuminate\Support\Facades\Crypt;
8: class PatientAppointmentBookMail extends Mailable
9: {
10: use Queueable, SerializesModels;
11: public $data;
12: /**
13: * Create a new message instance.
14: *
15: * @return void
16: */
17: public function __construct($data)
18: {
19: $this->data = $data;
20: }
21: /**
22: * Build the message.
23: */
24: public function build(): static
25: {
26: $name = $this->data['patient_name'];
27: $patientId = $this->data['patient_id'];
28: $appointmentUniqueId = Crypt::encryptString($this->data['appointment_unique_id']);
29: $time = $this->data['original_from_time'].' - '.$this->data['original_to_time'];
30: $date = Carbon::createFromFormat('Y-m-d', $this->data['date'])->format('dS,M Y');
31: $subject = 'Appointment Booked Successfully';
32: return $this->view('emails.patient_appointment_booked_mail',
33: compact('name', 'time', 'date', 'appointmentUniqueId', 'patientId'))
34: ->markdown('emails.patient_appointment_booked_mail')
35: ->subject($subject);
36: }
37: }
[app > MediaLibrary > CustomPathGenerator.php]
1: <?php
2: namespace App\MediaLibrary;
3: use App\Models\FrontPatientTestimonial;
4: use App\Models\Patient;
5: use App\Models\Service;
6: use App\Models\Setting;
7: use App\Models\Slider;
8: use App\Models\User;
9: use Spatie\MediaLibrary\MediaCollections\Models\Media;
10: use Spatie\MediaLibrary\Support\PathGenerator\PathGenerator;
11: /**
12: * Class CustomPathGenerator
13: */
14: class CustomPathGenerator implements PathGenerator
15: {
16: public function getPath(Media $media): string
17: {
18: $path = '{PARENT_DIR}'.DIRECTORY_SEPARATOR.$media->id.DIRECTORY_SEPARATOR;
19: switch ($media->collection_name) {
20: case User::PROFILE:
21: return str_replace('{PARENT_DIR}', User::PROFILE, $path);
22: case Patient::PROFILE:
23: return str_replace('{PARENT_DIR}', Patient::PROFILE, $path);
24: case Setting::LOGO:
25: return str_replace('{PARENT_DIR}', Setting::LOGO, $path);
26: case Setting::FAVICON:
27: return str_replace('{PARENT_DIR}', Setting::FAVICON, $path);
28: case Slider::SLIDER_IMAGE:
29: return str_replace('{PARENT_DIR}', Slider::SLIDER_IMAGE, $path);
30: case FrontPatientTestimonial::FRONT_PATIENT_PROFILE:
31: return str_replace('{PARENT_DIR}', FrontPatientTestimonial::FRONT_PATIENT_PROFILE,
$path);
32: case Service::ICON:
33: return str_replace('{PARENT_DIR}', Service::ICON, $path);
34: case 'default':
35: return '';
36: }
37: }
38: public function getPathForConversions(Media $media): string
39: {
40: return $this->getPath($media).'thumbnails/';
41: }
42: public function getPathForResponsiveImages(Media $media): string
43: {
44: return $this->getPath($media).'rs-images/';
45: }
46: }
[app > Models > Address.php]
1: <?php
2: namespace App\Models;
3: use Eloquent;
4: use Illuminate\Database\Eloquent\Factories\HasFactory;
5: use Illuminate\Database\Eloquent\Model;
6: use Illuminate\Database\Eloquent\Relations\MorphTo;
7: use Illuminate\Support\Carbon;
8: /**
9: * App\Models\Address
10: *
11: * @property int $id
12: * @property int|null $owner_id
13: * @property string|null $owner_type
14: * @property string|null $address1
15: * @property string|null $address2
16: * @property string|null $country
17: * @property string|null $state
18: * @property string|null $city
19: * @property string|null $postal_code
20: * @property Carbon|null $created_at
21: * @property Carbon|null $updated_at
22: * @property-read Model|Eloquent $owner
23: *
24: * @method static \Illuminate\Database\Eloquent\Builder|Address newModelQuery()
25: * @method static \Illuminate\Database\Eloquent\Builder|Address newQuery()
26: * @method static \Illuminate\Database\Eloquent\Builder|Address query()
27: * @method static \Illuminate\Database\Eloquent\Builder|Address whereAddress1($value)
28: * @method static \Illuminate\Database\Eloquent\Builder|Address whereAddress2($value)
29: * @method static \Illuminate\Database\Eloquent\Builder|Address whereCity($value)
30: * @method static \Illuminate\Database\Eloquent\Builder|Address whereCountry($value)
31: * @method static \Illuminate\Database\Eloquent\Builder|Address whereCreatedAt($value)
32: * @method static \Illuminate\Database\Eloquent\Builder|Address whereId($value)
33: * @method static \Illuminate\Database\Eloquent\Builder|Address whereOwnerId($value)
34: * @method static \Illuminate\Database\Eloquent\Builder|Address whereOwnerType($value)
35: * @method static \Illuminate\Database\Eloquent\Builder|Address
wherePostalCode($value)
36: * @method static \Illuminate\Database\Eloquent\Builder|Address whereState($value)
37: * @method static \Illuminate\Database\Eloquent\Builder|Address whereUpdatedAt($value)
38: *
39: * @mixin Eloquent
40: *
41: * @property int|null $country_id
42: * @property int|null $state_id
43: * @property int|null $city_id
44: *
45: * @method static \Illuminate\Database\Eloquent\Builder|Address whereCityId($value)
46: * @method static \Illuminate\Database\Eloquent\Builder|Address whereCountryId($value)
47: * @method static \Illuminate\Database\Eloquent\Builder|Address whereStateId($value)
48: */
49: class Address extends Model
50: {
51: use HasFactory;
52: protected $table = 'addresses';
53: protected $fillable = [
54: 'address1',
55: 'address2',
56: 'country_id',
57: 'state_id',
58: 'city_id',
59: 'postal_code',
60: ];
61: public function owner(): MorphTo
62: {
63: return $this->morphTo();
64: }
65: }
[app > Models > Appointment.php]
1: <?php
2: namespace App\Models;
3: use Eloquent as Model;
4: use Illuminate\Database\Eloquent\Builder;
5: use Illuminate\Database\Eloquent\Factories\HasFactory;
6: use Illuminate\Database\Eloquent\Relations\BelongsTo;
7: use Illuminate\Support\Carbon;
8: use Illuminate\Support\Str;
9: /**
10: * App\Models\Appointment
11: *
12: * @property int $id
13: * @property int $doctor_id
14: * @property int $patient_id
15: * @property string $date
16: * @property string $from_time
17: * @property string $from_time_type
18: * @property string $to_time
19: * @property string $to_time_type
20: * @property int $status
21: * @property string|null $description
22: * @property int $service_id
23: * @property string $payable_amount
24: * @property Carbon|null $created_at
25: * @property Carbon|null $updated_at
26: * @property-read \App\Models\Doctor $doctor
27: * @property-read \App\Models\Patient $patient
28: * @property-read \App\Models\Service $services
29: * @property-read \App\Models\User $user
30: *
31: * @method static \Database\Factories\AppointmentFactory factory(...$parameters)
32: * @method static Builder|Appointment newModelQuery()
33: * @method static Builder|Appointment newQuery()
34: * @method static Builder|Appointment query()
35: * @method static Builder|Appointment whereCreatedAt($value)
36: * @method static Builder|Appointment whereDate($value)
37: * @method static Builder|Appointment whereDescription($value)
38: * @method static Builder|Appointment whereDoctorId($value)
39: * @method static Builder|Appointment whereFromTime($value)
40: * @method static Builder|Appointment whereFromTimeType($value)
41: * @method static Builder|Appointment whereId($value)
42: * @method static Builder|Appointment wherePatientId($value)
43: * @method static Builder|Appointment wherePayableAmount($value)
44: * @method static Builder|Appointment whereServiceId($value)
45: * @method static Builder|Appointment whereStatus($value)
46: * @method static Builder|Appointment whereToTime($value)
47: * @method static Builder|Appointment whereToTimeType($value)
48: * @method static Builder|Appointment whereUpdatedAt($value)
49: *
50: * @mixin Model
51: *
52: * @property string $appointment_unique_id
53: *
54: * @method static Builder|Appointment whereAppointmentUniqueId($value)
55: *
56: * @property-read mixed $status_name
57: */
58: class Appointment extends Model
59: {
60: use HasFactory;
61: public $table = 'appointments';
62: public $fillable = [
63: 'doctor_id',
64: 'patient_id',
65: 'date',
66: 'from_time',
67: 'description',
68: 'status',
69: 'to_time',
70: 'service_id',
71: 'payable_amount',
72: 'appointment_unique_id',
73: 'from_time_type',
74: 'to_time_type',
75: 'payment_type',
76: 'payment_method',
77: ];
78: protected $casts = [
79: 'doctor_id' => 'integer',
80: 'patient_id' => 'integer',
81: 'date' => 'string',
82: 'from_time' => 'string',
83: 'description' => 'string',
84: 'status' => 'integer',
85: 'to_time' => 'string',
86: 'service_id' => 'integer',
87: 'payable_amount' => 'string',
88: 'appointment_unique_id' => 'string',
89: 'from_time_type' => 'string',
90: 'to_time_type' => 'string',
91: ];
92: const ALL = 0;
93: const BOOKED = 1;
94: const CHECK_IN = 2;
95: const CHECK_OUT = 3;
96: const CANCELLED = 4;
97: const STATUS = [
98: self::ALL => 'All',
99: self::BOOKED => 'Booked',
100: self::CHECK_IN => 'Check In',
101: self::CHECK_OUT => 'Check Out',
102: self::CANCELLED => 'Cancelled',
103: ];
104: const ALL_STATUS = [
105: self::ALL => 'All',
106: self::BOOKED => 'Booked',
107: self::CHECK_IN => 'Check In',
108: self::CHECK_OUT => 'Check Out',
109: self::CANCELLED => 'Cancelled',
110: ];
111: const BOOKED_STATUS_ARRAY = [
112: self::BOOKED => 'Booked',
113: ];
114: const PATIENT_STATUS = [
115: self::BOOKED => 'Booked',
116: self::CANCELLED => 'Cancelled',
117: ];
118: const ALL_PAYMENT = 0;
119: const PENDING = 1;
120: const PAID = 2;
121: const PAYMENT_TYPE = [
122: self::PENDING => 'Pending',
123: self::PAID => 'Paid',
124: ];
125: const PAYMENT_TYPE_ALL = [
126: self::ALL_PAYMENT => 'All',
127: self::PENDING => 'Pending',
128: self::PAID => 'Paid',
129: ];
130: const MANUALLY = 1;
131: const STRIPE = 2;
132: const PAYSTACK = 3;
133: const PAYPAL = 4;
134: const RAZORPAY = 5;
135: const AUTHORIZE = 6;
136: const PAYTM = 7;
137: const PAYMENT_METHOD = [
138: self::MANUALLY => 'Manually',
139: self::STRIPE => 'Stripe',
140: self::PAYSTACK => 'Paystack',
141: self::PAYPAL => 'Paypal',
142: self::RAZORPAY => 'Razorpay',
143: self::AUTHORIZE => 'Authorize',
144: self::PAYTM => 'Paytm',
145: ];
146: const PAYMENT_GATEWAY = [
147: self::STRIPE => 'Stripe',
148: self::PAYSTACK => 'Paystack',
149: self::PAYPAL => 'Paypal',
150: self::RAZORPAY => 'Razorpay',
151: self::AUTHORIZE => 'Authorize',
152: self::PAYTM => 'Paytm',
153: ];
154: /**
155: * Validation rules
156: *
157: * @var array
158: */
159: public static $rules = [
160: 'doctor_id' => 'required',
161: 'patient_id' => 'required',
162: 'date' => 'required',
163: 'service_id' => 'required',
164: 'payable_amount' => 'required',
165: 'from_time' => 'required',
166: 'to_time' => 'required',
167: 'payment_type' => 'required',
168: ];
169: public static function generateAppointmentUniqueId(): string
170: {
171: $appointmentUniqueId = Str::random(10);
172: while (true) {
173: $isExist = self::whereAppointmentUniqueId($appointmentUniqueId)->exists();
174: if ($isExist) {
175: self::generateAppointmentUniqueId();
176: }
177: break;
178: }
179: return $appointmentUniqueId;
180: }
181: public function getStatusNameAttribute()
182: {
183: return self::STATUS[$this->status];
184: }
185: public function doctor(): BelongsTo
186: {
187: return $this->belongsTo(Doctor::class, 'doctor_id');
188: }
189: public function patient(): BelongsTo
190: {
191: return $this->belongsTo(Patient::class, 'patient_id');
192: }
193: /**
194: * @return mixed
195: */
196: public function services()
197: {
198: return $this->belongsTo(Service::class, 'service_id');
199: }
200: /**
201: * @return mixed
202: */
203: public function user()
204: {
205: return $this->belongsTo(User::class, 'user_id');
206: }
207: /**
208: * @return mixed
209: */
210: public function transaction()
211: {
212: return $this->hasOne(Transaction::class, 'appointment_id', 'appointment_unique_id');
213: }
214: }
[app > Models > AppointmentGoogleCalendar.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: use Illuminate\Database\Eloquent\Relations\BelongsTo;
6: /**
7: * App\Models\AppointmentGoogleCalendar
8: *
9: * @property int $id
10: * @property int $user_id
11: * @property int $google_calendar_list_id
12: * @property string $google_calendar_id
13: * @property \Illuminate\Support\Carbon|null $created_at
14: * @property \Illuminate\Support\Carbon|null $updated_at
15: * @property-read \App\Models\GoogleCalendarList $googleCalendarList
16: *
17: * @method static \Illuminate\Database\Eloquent\Builder|AppointmentGoogleCalendar
18: newModelQuery()
19: * @method static \Illuminate\Database\Eloquent\Builder|AppointmentGoogleCalendar
20: newQuery()
21: * @method static \Illuminate\Database\Eloquent\Builder|AppointmentGoogleCalendar
query()
22: * @method static \Illuminate\Database\Eloquent\Builder|AppointmentGoogleCalendar
23: whereCreatedAt($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|AppointmentGoogleCalendar
25: whereGoogleCalendarId($value)
26: * @method static \Illuminate\Database\Eloquent\Builder|AppointmentGoogleCalendar
27: whereGoogleCalendarListId($value)
28: * @method static \Illuminate\Database\Eloquent\Builder|AppointmentGoogleCalendar
29: whereId($value)
30: * @method static \Illuminate\Database\Eloquent\Builder|AppointmentGoogleCalendar
31: whereUpdatedAt($value)
32: * @method static \Illuminate\Database\Eloquent\Builder|AppointmentGoogleCalendar
33: whereUserId($value)
34: *
35: * @mixin \Eloquent
36: */
37: class AppointmentGoogleCalendar extends Model
38: {
39: use HasFactory;
40: public $fillable = [
41: 'user_id',
42: 'google_calendar_list_id',
43: 'google_calendar_id',
44: ];
45: public function googleCalendarList(): BelongsTo
46: {
47: return $this->BelongsTo(GoogleCalendarList::class);
48: }
49: }
[app > Models > Brand.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Model;
4: use Illuminate\Database\Eloquent\Relations\BelongsTo;
5: use Illuminate\Database\Eloquent\Relations\HasMany;
6: /**
7: * App\Models\Brand
8: *
9: * @property int $id
10: * @property string $name
11: * @property string|null $email
12: * @property string|null $phone
13: * @property \Illuminate\Support\Carbon|null $created_at
14: * @property \Illuminate\Support\Carbon|null $updated_at
15: * @property-read \App\Models\Category|null $category
16: * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Medicine[]
17: $medicines
18: * @property-read int|null $medicines_count
19: *
20: * @method static \Illuminate\Database\Eloquent\Builder|Brand newModelQuery()
21: * @method static \Illuminate\Database\Eloquent\Builder|Brand newQuery()
22: * @method static \Illuminate\Database\Eloquent\Builder|Brand query()
23: * @method static \Illuminate\Database\Eloquent\Builder|Brand whereCreatedAt($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|Brand whereEmail($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|Brand whereId($value)
26: * @method static \Illuminate\Database\Eloquent\Builder|Brand whereName($value)
27: * @method static \Illuminate\Database\Eloquent\Builder|Brand wherePhone($value)
28: * @method static \Illuminate\Database\Eloquent\Builder|Brand whereUpdatedAt($value)
29: *
30: * @mixin \Eloquent
31: */
32: class Brand extends Model
33: {
34: public $table = 'brands';
35: public $fillable = [
36: 'name',
37: 'email',
38: 'phone',
39: ];
40: /**
41: * The attributes that should be casted to native types.
42: *
43: * @var array
44: */
45: protected $casts = [
46: 'id' => 'integer',
47: 'name' => 'string',
48: 'email' => 'string',
49: 'phone' => 'string',
50: ];
51: /**
52: * Validation rules
53: *
54: * @var array
55: */
56: public static $rules = [
57: 'name' => 'required|unique:brands,name',
58: 'email' => 'email|unique:brands,email|nullable',
59: 'phone' => 'nullable|numeric',
60: ];
61: public function medicines(): HasMany
62: {
63: return $this->hasMany(Medicine::class, 'brand_id');
64: }
65: public function category(): BelongsTo
66: {
67: return $this->belongsTo(Category::class, 'category_id');
68: }
69: }
[app > Models > Category.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: use Illuminate\Database\Eloquent\Relations\BelongsTo;
6: use Illuminate\Database\Eloquent\Relations\HasMany;
7: use Illuminate\Support\Carbon;
8: /**
9: * App\Models\Category
10: *
11: * @property int $id
12: * @property string $name
13: * @property int $is_active
14: * @property Carbon|null $created_at
15: * @property Carbon|null $updated_at
16: * @property-read \App\Models\Brand|null $brand
17: * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Medicine[]
18: $medicines
19: * @property-read int|null $medicines_count
20: *
21: * @method static \Illuminate\Database\Eloquent\Builder|Category newModelQuery()
22: * @method static \Illuminate\Database\Eloquent\Builder|Category newQuery()
23: * @method static \Illuminate\Database\Eloquent\Builder|Category query()
24: * @method static \Illuminate\Database\Eloquent\Builder|Category
whereCreatedAt($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|Category whereId($value)
26: * @method static \Illuminate\Database\Eloquent\Builder|Category whereIsActive($value)
27: * @method static \Illuminate\Database\Eloquent\Builder|Category whereName($value)
28: * @method static \Illuminate\Database\Eloquent\Builder|Category
whereUpdatedAt($value)
29: *
30: * @mixin \Eloquent
31: */
32: class Category extends Model
33: {
34: use HasFactory;
35: public $table = 'categories';
36: public $fillable = [
37: 'name', 'is_active',
38: ];
39: const STATUS_ALL = 2;
40: const ACTIVE = 1;
41: const INACTIVE = 0;
42: const STATUS_ARR = [
43: self::STATUS_ALL => 'All',
44: self::ACTIVE => 'Active',
45: self::INACTIVE => 'Deactive',
46: ];
47: /**
48: * The attributes that should be casted to native types.
49: *
50: * @var array
51: */
52: protected $casts = [
53: 'deleted_at' => 'datetime',
54: 'id' => 'integer',
55: 'name' => 'string',
56: 'is_active' => 'integer', ];
57: /**
58: * Validation rules
59: *
60: * @var array
61: */
62: public static $rules = [
63: 'name' => 'required|unique:categories,name',
64: ];
65: public function medicines(): HasMany
66: {
67: return $this->hasMany(Medicine::class, 'category_id');
68: }
69: public function brand(): BelongsTo
70: {
71: return $this->belongsTo(Brand::class);
72: }
73: }
[app > Models > City.php]
1: <?php
2: namespace App\Models;
3: use Eloquent as Model;
4: use Illuminate\Database\Eloquent\Factories\HasFactory;
5: use Illuminate\Database\Eloquent\Relations\BelongsTo;
6: use Illuminate\Support\Carbon;
7: /**
8: * Class City
9: *
10: * @version July 31, 2021, 7:41 am UTC
11: *
12: * @property string $name
13: * @property string $state_id
14: * @property int $id
15: * @property Carbon|null $created_at
16: * @property Carbon|null $updated_at
17: * @property-read State $state
18: *
19: * @method static \Database\Factories\CityFactory factory(...$parameters)
20: * @method static \Illuminate\Database\Eloquent\Builder|City newModelQuery()
21: * @method static \Illuminate\Database\Eloquent\Builder|City newQuery()
22: * @method static \Illuminate\Database\Eloquent\Builder|City query()
23: * @method static \Illuminate\Database\Eloquent\Builder|City whereCreatedAt($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|City whereId($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|City whereName($value)
26: * @method static \Illuminate\Database\Eloquent\Builder|City whereStateId($value)
27: * @method static \Illuminate\Database\Eloquent\Builder|City whereUpdatedAt($value)
28: *
29: * @mixin Model
30: */
31: class City extends Model
32: {
33: use HasFactory;
34: public $table = 'cities';
35: public $fillable = [
36: 'name',
37: 'state_id',
38: ];
39: /**
40: * The attributes that should be casted to native types.
41: *
42: * @var array
43: */
44: protected $casts = [
45: 'name' => 'string',
46: 'state_id' => 'string',
47: ];
48: /**
49: * Validation rules
50: *
51: * @var array
52: */
53: public static $rules = [
54: 'name' => 'required|unique:cities,name',
55: ];
56: public function state(): BelongsTo
57: {
58: return $this->belongsTo(State::class, 'state_id');
59: }
60: }
[app > Models > ClinicSchedule.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: /**
6: * App\Models\ClinicSchedule
7: *
8: * @property int $id
9: * @property string $day_of_week
10: * @property string $start_time
11: * @property string $end_time
12: * @property \Illuminate\Support\Carbon|null $created_at
13: * @property \Illuminate\Support\Carbon|null $updated_at
14: *
15: * @method static \Illuminate\Database\Eloquent\Builder|ClinicSchedule newModelQuery()
16: * @method static \Illuminate\Database\Eloquent\Builder|ClinicSchedule newQuery()
17: * @method static \Illuminate\Database\Eloquent\Builder|ClinicSchedule query()
18: * @method static \Illuminate\Database\Eloquent\Builder|ClinicSchedule
19: whereCreatedAt($value)
20: * @method static \Illuminate\Database\Eloquent\Builder|ClinicSchedule
21: whereDayOfWeek($value)
22: * @method static \Illuminate\Database\Eloquent\Builder|ClinicSchedule
whereEndTime($value)
23: * @method static \Illuminate\Database\Eloquent\Builder|ClinicSchedule whereId($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|ClinicSchedule
25: whereStartTime($value)
26: * @method static \Illuminate\Database\Eloquent\Builder|ClinicSchedule
27: whereUpdatedAt($value)
28: *
29: * @mixin \Eloquent
30: */
31: class ClinicSchedule extends Model
32: {
33: use HasFactory;
34: protected $table = 'clinic_schedules';
35: const Mon = 1;
36: const Tue = 2;
37: const Wed = 3;
38: const Thu = 4;
39: const Fri = 5;
40: const Sat = 6;
41: const Sun = 0;
42: const WEEKDAY = [
43: self::Mon => 'MON',
44: self::Tue => 'TUE',
45: self::Wed => 'WED',
46: self::Thu => 'THU',
47: self::Fri => 'FRI',
48: self::Sat => 'SAT',
49: self::Sun => 'SUN',
50: ];
51: const WEEKDAY_FULL_NAME = [
52: self::Mon => 'Monday',
53: self::Tue => 'Tuesday',
54: self::Wed => 'Wednesday',
55: self::Thu => 'Thursday',
56: self::Fri => 'Friday',
57: self::Sat => 'Saturday',
58: self::Sun => 'Sunday',
59: ];
60: public $fillable = [
61: 'day_of_week',
62: 'start_time',
63: 'end_time',
64: ];
65: protected $casts = [
66: 'day_of_week' => 'string',
67: 'start_time' => 'string',
68: 'end_time' => 'string',
69: ];
70: }
[app > Models > Country.php]
1: <?php
2: namespace App\Models;
3: use Eloquent as Model;
4: use Illuminate\Database\Eloquent\Factories\HasFactory;
5: use Illuminate\Support\Carbon;
6: /**
7: * Class Country
8: *
9: * @version July 29, 2021, 10:49 am UTC
10: *
11: * @property string $name
12: * @property string $short_code
13: * @property int $id
14: * @property string|null $phone_code
15: * @property Carbon|null $created_at
16: * @property Carbon|null $updated_at
17: * @property string|null $deleted_at
18: *
19: * @method static \Database\Factories\CountryFactory factory(...$parameters)
20: * @method static \Illuminate\Database\Eloquent\Builder|Country newModelQuery()
21: * @method static \Illuminate\Database\Eloquent\Builder|Country newQuery()
22: * @method static \Illuminate\Database\Eloquent\Builder|Country query()
23: * @method static \Illuminate\Database\Eloquent\Builder|Country whereCreatedAt($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|Country whereDeletedAt($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|Country whereId($value)
26: * @method static \Illuminate\Database\Eloquent\Builder|Country whereName($value)
27: * @method static \Illuminate\Database\Eloquent\Builder|Country wherePhoneCode($value)
28: * @method static \Illuminate\Database\Eloquent\Builder|Country whereShortCode($value)
29: * @method static \Illuminate\Database\Eloquent\Builder|Country whereUpdatedAt($value)
30: *
31: * @mixin Model
32: */
33: class Country extends Model
34: {
35: use HasFactory;
36: protected $table = 'countries';
37: public $fillable = [
38: 'name',
39: 'short_code',
40: ];
41: /**
42: * The attributes that should be casted to native types.
43: *
44: * @var array
45: */
46: protected $casts = [
47: 'name' => 'string',
48: 'short_code' => 'string',
49: ];
50: /**
51: * Validation rules
52: *
53: * @var array
54: */
55: public static $rules = [
56: 'name' => 'required|unique:countries,name',
57: ];
58: }
[app > Models > Currency.php]
1: <?php
2: namespace App\Models;
3: use Eloquent as Model;
4: use Illuminate\Database\Eloquent\Builder;
5: use Illuminate\Database\Eloquent\Factories\HasFactory;
6: use Illuminate\Support\Carbon;
7: /**
8: * Class Currency
9: *
10: * @version August 26, 2021, 6:57 am UTC
11: *
12: * @property string $currency_name
13: * @property string $currency_icon
14: * @property string $currency_code
15: * @property int $id
16: * @property Carbon|null $created_at
17: * @property Carbon|null $updated_at
18: *
19: * @method static \Database\Factories\CurrencyFactory factory(...$parameters)
20: * @method static Builder|Currency newModelQuery()
21: * @method static Builder|Currency newQuery()
22: * @method static Builder|Currency query()
23: * @method static Builder|Currency whereCreatedAt($value)
24: * @method static Builder|Currency whereCurrencyCode($value)
25: * @method static Builder|Currency whereCurrencyIcon($value)
26: * @method static Builder|Currency whereCurrencyName($value)
27: * @method static Builder|Currency whereId($value)
28: * @method static Builder|Currency whereUpdatedAt($value)
29: *
30: * @mixin Model
31: */
32: class Currency extends Model
33: {
34: use HasFactory;
35: public $table = 'currencies';
36: public $fillable = [
37: 'currency_name',
38: 'currency_icon',
39: 'currency_code',
40: ];
41: /**
42: * The attributes that should be casted to native types.
43: *
44: * @var array
45: */
46: protected $casts = [
47: 'currency_name' => 'string',
48: 'currency_icon' => 'string',
49: 'currency_code' => 'string',
50: ];
51: /**
52: * Validation rules
53: *
54: * @var array
55: */
56: public static $rules = [
57: 'currency_name' => 'required|unique:currencies',
58: 'currency_icon' => 'required',
59: 'currency_code' => 'required|min:3|max:3',
60: ];
61: }
[app > Models > Doctor.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: use Illuminate\Database\Eloquent\Relations\BelongsTo;
6: use Illuminate\Database\Eloquent\Relations\BelongsToMany;
7: use Illuminate\Database\Eloquent\Relations\HasMany;
8: use Illuminate\Support\Carbon;
9: /**
10: * App\Models\Doctor
11: *
12: * @property int $id
13: * @property int $user_id
14: * @property float|null $experience
15: * @property Carbon|null $created_at
16: * @property Carbon|null $updated_at
17: * @property-read
\Illuminate\Database\Eloquent\Collection|\App\Models\Specialization[]
18: $specializations
19: * @property-read int|null $specializations_count
20: * @property-read \App\Models\User $user
21: *
22: * @method static \Illuminate\Database\Eloquent\Builder|Doctor newModelQuery()
23: * @method static \Illuminate\Database\Eloquent\Builder|Doctor newQuery()
24: * @method static \Illuminate\Database\Eloquent\Builder|Doctor query()
25: * @method static \Illuminate\Database\Eloquent\Builder|Doctor whereCreatedAt($value)
26: * @method static \Illuminate\Database\Eloquent\Builder|Doctor whereExperience($value)
27: * @method static \Illuminate\Database\Eloquent\Builder|Doctor whereId($value)
28: * @method static \Illuminate\Database\Eloquent\Builder|Doctor whereUpdatedAt($value)
29: * @method static \Illuminate\Database\Eloquent\Builder|Doctor whereUserId($value)
30: *
31: * @mixin \Eloquent
32: *
33: * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Appointment[]
34: $appointments
35: * @property-read int|null $appointments_count
36: * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\DoctorSession[]
37: $doctorSession
38: * @property-read int|null $doctor_session_count
39: * @property string|null $twitter_url
40: * @property string|null $linkedin_url
41: * @property string|null $instagram_url
42: *
43: * @method static \Illuminate\Database\Eloquent\Builder|Doctor
whereInstagramUrl($value)
44: * @method static \Illuminate\Database\Eloquent\Builder|Doctor
whereLinkedinUrl($value)
45: * @method static \Illuminate\Database\Eloquent\Builder|Doctor whereTwitterUrl($value)
46: */
47: class Doctor extends Model
48: {
49: use HasFactory;
50: protected $table = 'doctors';
51: /**
52: * @var string[]
53: */
54: protected $fillable = [
55: 'user_id',
56: 'specialization',
57: 'experience',
58: 'twitter_url',
59: 'linkedin_url',
60: 'instagram_url',
61: ];
62: protected $casts = [
63: 'user_id' => 'integer',
64: 'twitter_url' => 'string',
65: 'linkedin_url' => 'string',
66: 'instagram_url' => 'string',
67: ];
68: const O_POSITIVE = 1;
69: const A_POSITIVE = 2;
70: const B_POSITIVE = 3;
71: const AB_POSITIVE = 4;
72: const O_NEGATIVE = 5;
73: const A_NEGATIVE = 6;
74: const B_NEGATIVE = 7;
75: const AB_NEGATIVE = 8;
76: const BLOOD_GROUP_ARRAY = [
77: self::O_POSITIVE => 'O+',
78: self::A_POSITIVE => 'A+',
79: self::B_POSITIVE => 'B+',
80: self::AB_POSITIVE => 'AB+',
81: self::O_NEGATIVE => 'O-',
82: self::A_NEGATIVE => 'A-',
83: self::B_NEGATIVE => 'B-',
84: self::AB_NEGATIVE => 'AB-',
85: ];
86: public function user(): BelongsTo
87: {
88: return $this->belongsTo(User::class, 'user_id');
89: }
90: public function doctorUser(): BelongsTo
91: {
92: return $this->belongsTo(User::class, 'user_id');
93: }
94: public function testUser(): BelongsTo
95: {
96: return $this->belongsTo(User::class, 'user_id');
97: }
98: public function specializations(): BelongsToMany
99: {
100: return $this->belongsToMany(Specialization::class, 'doctor_specialization',
'doctor_id',
101: 'specialization_id');
102: }
103: public function doctorSession(): HasMany
104: {
105: return $this->hasMany(DoctorSession::class);
106: }
107: public function appointments(): HasMany
108: {
109: return $this->hasMany(Appointment::class);
110: }
111: public function reviews(): HasMany
112: {
113: return $this->hasMany(Review::class);
114: }
115: }
[app > Models > DoctorHoliday.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: /**
6: * App\Models\DoctorHoliday
7: *
8: * @property int $id
9: * @property string|null $name
10: * @property int $doctor_id
11: * @property string $date
12: * @property \Illuminate\Support\Carbon|null $created_at
13: * @property \Illuminate\Support\Carbon|null $updated_at
14: * @property-read \App\Models\Doctor $doctor
15: *
16: * @method static \Illuminate\Database\Eloquent\Builder|DoctorHoliday newModelQuery()
17: * @method static \Illuminate\Database\Eloquent\Builder|DoctorHoliday newQuery()
18: * @method static \Illuminate\Database\Eloquent\Builder|DoctorHoliday query()
19: * @method static \Illuminate\Database\Eloquent\Builder|DoctorHoliday
20: whereCreatedAt($value)
21: * @method static \Illuminate\Database\Eloquent\Builder|DoctorHoliday
whereDate($value)
22: * @method static \Illuminate\Database\Eloquent\Builder|DoctorHoliday
whereDoctorId($value)
23: * @method static \Illuminate\Database\Eloquent\Builder|DoctorHoliday whereId($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|DoctorHoliday
whereName($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|DoctorHoliday
26: whereUpdatedAt($value)
27: *
28: * @mixin \Eloquent
29: */
30: class DoctorHoliday extends Model
31: {
32: use HasFactory;
33: public $table = 'doctor_holidays';
34: public $fillable = [
35: 'doctor_id',
36: 'date',
37: 'name',
38: ];
39: public static $rules = [
40: 'doctor_id' => 'required',
41: 'date' => 'required',
42: ];
43: const ALL = 0;
44: const UPCOMING_HOLIDAY = 1;
45: const PAST_HOLIDAY = 2;
46: const TODAY = 3;
47: const ALL_STATUS = [
48: self::ALL => 'All',
49: self::TODAY => 'Today',
50: self::UPCOMING_HOLIDAY => 'Upcoming Holidays',
51: self::PAST_HOLIDAY => 'Past Holidays',
52: ];
53: public function doctor()
54: {
55: return $this->belongsTo(Doctor::class, 'doctor_id');
56: }
57: }
[app > Models > DoctorSession.php]
1: <?php
2: namespace App\Models;
3: use Database\Factories\DoctorSessionFactory;
4: use Illuminate\Database\Eloquent\Builder;
5: use Illuminate\Database\Eloquent\Collection;
6: use Illuminate\Database\Eloquent\Factories\HasFactory;
7: use Illuminate\Database\Eloquent\Model;
8: use Illuminate\Database\Eloquent\Relations\BelongsTo;
9: use Illuminate\Database\Eloquent\Relations\HasMany;
10: use Illuminate\Support\Carbon;
11: /**
12: * App\Models\DoctorSession
13: *
14: * @property int $id
15: * @property int $doctor_id
16: * @property string $session_meeting_time
17: * @property string $session_gap
18: * @property Carbon|null $created_at
19: * @property Carbon|null $updated_at
20: * @property-read Doctor $doctor
21: * @property-read Collection|WeekDay[] $sessionWeekDays
22: * @property-read int|null $session_week_days_count
23: *
24: * @method static DoctorSessionFactory factory(...$parameters)
25: * @method static Builder|DoctorSession newModelQuery()
26: * @method static Builder|DoctorSession newQuery()
27: * @method static Builder|DoctorSession query()
28: * @method static Builder|DoctorSession whereCreatedAt($value)
29: * @method static Builder|DoctorSession whereDoctorId($value)
30: * @method static Builder|DoctorSession whereId($value)
31: * @method static Builder|DoctorSession whereSessionGap($value)
32: * @method static Builder|DoctorSession whereSessionMeetingTime($value)
33: * @method static Builder|DoctorSession whereUpdatedAt($value)
34: */
35: class DoctorSession extends Model
36: {
37: use HasFactory;
38: /**
39: * @var string
40: */
41: protected $table = 'doctor_sessions';
42: /**
43: * @var string[]
44: */
45: protected $fillable = [
46: 'doctor_id',
47: 'session_meeting_time',
48: 'session_gap',
49: ];
50: protected $casts = [
51: 'doctor_id' => 'integer',
52: 'session_meeting_time' => 'integer',
53: 'session_gap' => 'string',
54: ];
55: const MALE = 1;
56: const FEMALE = 2;
57: const GENDER = [
58: self::MALE => 'Male',
59: self::FEMALE => 'Female',
60: ];
61: const GAPS = [
62: '5' => '5 minutes',
63: '10' => '10 minutes',
64: '15' => '15 minutes',
65: '20' => '20 minutes',
66: '25' => '25 minutes',
67: '30' => '30 minutes',
68: '45' => '45 minutes',
69: '60' => '1 hour',
70: ];
71: const SESSION_MEETING_TIME = [
72: '5' => '5 minutes',
73: '10' => '10 minutes',
74: '15' => '15 minutes',
75: '30' => '30 minutes',
76: '45' => '45 minutes',
77: '60' => '1 hour',
78: '90' => '1.5 hour',
79: '120' => '2 hour',
80: ];
81: /**
82: * Validation rules
83: *
84: * @var array
85: */
86: public static $rules = [
87: 'doctor_id' => 'required',
88: 'session_meeting_time' => 'required',
89: 'session_gap' => 'required',
90: ];
91: public function sessionWeekDays(): HasMany
92: {
93: return $this->hasMany(WeekDay::class);
94: }
95: public function doctor(): BelongsTo
96: {
97: return $this->belongsTo(Doctor::class);
98: }
99: }
[app > Models > Enquiry.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: /**
6: * App\Models\Enquiry
7: *
8: * @method static \Illuminate\Database\Eloquent\Builder|Enquiry newModelQuery()
9: * @method static \Illuminate\Database\Eloquent\Builder|Enquiry newQuery()
10: * @method static \Illuminate\Database\Eloquent\Builder|Enquiry query()
11: *
12: * @mixin \Eloquent
13: *
14: * @property int $id
15: * @property string $name
16: * @property string $email
17: * @property string|null $phone
18: * @property string $subject
19: * @property string $message
20: * @property \Illuminate\Support\Carbon|null $created_at
21: * @property \Illuminate\Support\Carbon|null $updated_at
22: * @property int $view
23: *
24: * @method static \Illuminate\Database\Eloquent\Builder|Enquiry whereCreatedAt($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|Enquiry whereEmail($value)
26: * @method static \Illuminate\Database\Eloquent\Builder|Enquiry whereId($value)
27: * @method static \Illuminate\Database\Eloquent\Builder|Enquiry whereMessage($value)
28: * @method static \Illuminate\Database\Eloquent\Builder|Enquiry whereName($value)
29: * @method static \Illuminate\Database\Eloquent\Builder|Enquiry wherePhone($value)
30: * @method static \Illuminate\Database\Eloquent\Builder|Enquiry whereSubject($value)
31: * @method static \Illuminate\Database\Eloquent\Builder|Enquiry whereUpdatedAt($value)
32: * @method static \Illuminate\Database\Eloquent\Builder|Enquiry whereView($value)
33: */
34: class Enquiry extends Model
35: {
36: use HasFactory;
37: protected $table = 'enquiries';
38: public $fillable = [
39: 'name',
40: 'email',
41: 'subject',
42: 'message',
43: 'phone',
44: 'view',
45: 'region_code',
46: ];
47: protected $casts = [
48: 'name' => 'string',
49: 'email' => 'string',
50: 'subject' => 'string',
51: 'message' => 'string',
52: 'phone' => 'string',
53: 'view' => 'boolean',
54: 'region_code' => 'string',
55: ];
56: protected $appends = ['view_name'];
57: const ALL = 2;
58: const READ = 1;
59: const UNREAD = 0;
60: const VIEW_NAME = [
61: self::ALL => 'All',
62: self::READ => 'Read',
63: self::UNREAD => 'Unread',
64: ];
65: public static $rules = [
66: 'name' => 'required',
67: 'email' =>
68: 'required|email|max:255|regex:/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[
a-z]{2,6}$/ix',
69: 'message' => 'required',
70: 'subject' => 'required',
71: ];
72: public function getViewNameAttribute(): string
73: {
74: return self::VIEW_NAME[$this->view];
75: }
76: }
[app > Models > Faq.php]
1: <?php
2: namespace App\Models;
3: use Eloquent as Model;
4: use Illuminate\Database\Eloquent\Factories\HasFactory;
5: use Illuminate\Support\Carbon;
6: /**
7: * Class Faq
8: *
9: * @version September 21, 2021, 12:51 pm UTC
10: *
11: * @property int $id
12: * @property string $question
13: * @property string $answer
14: * @property int $is_default
15: * @property Carbon|null $created_at
16: * @property Carbon|null $updated_at
17: *
18: * @method static \Database\Factories\FaqFactory factory(...$parameters)
19: * @method static \Illuminate\Database\Eloquent\Builder|Faq newModelQuery()
20: * @method static \Illuminate\Database\Eloquent\Builder|Faq newQuery()
21: * @method static \Illuminate\Database\Eloquent\Builder|Faq query()
22: * @method static \Illuminate\Database\Eloquent\Builder|Faq whereAnswer($value)
23: * @method static \Illuminate\Database\Eloquent\Builder|Faq whereCreatedAt($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|Faq whereId($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|Faq whereIsDefault($value)
26: * @method static \Illuminate\Database\Eloquent\Builder|Faq whereQuestion($value)
27: * @method static \Illuminate\Database\Eloquent\Builder|Faq whereUpdatedAt($value)
28: *
29: * @mixin Model
30: */
31: class Faq extends Model
32: {
33: use HasFactory;
34: public $table = 'faqs';
35: public $fillable = [
36: 'question',
37: 'answer',
38: 'is_default',
39: ];
40: protected $casts = [
41: 'question' => 'string',
42: 'answer' => 'string',
43: 'is_default' => 'boolean',
44: ];
45: /**
46: * Validation rules
47: *
48: * @var array
49: */
50: public static $rules = [
51: 'question' => 'required',
52: 'answer' => 'required|max:1000',
53: ];
54: }
[app > Models > FrontPatientTestimonial.php]
1: <?php
2: namespace App\Models;
3: use Eloquent as Model;
4: use Illuminate\Database\Eloquent\Factories\HasFactory;
5: use Illuminate\Support\Carbon;
6: use Spatie\MediaLibrary\HasMedia;
7: use Spatie\MediaLibrary\InteractsWithMedia;
8: use Spatie\MediaLibrary\MediaCollections\Models\Media;
9: /**
10: * Class FrontPatientTestimonial
11: *
12: * @version September 22, 2021, 11:20 am UTC
13: *
14: * @property int $id
15: * @property string $name
16: * @property string $designation
17: * @property string $short_description
18: * @property int $is_default
19: * @property Carbon|null $created_at
20: * @property Carbon|null $updated_at
21: *
22: * @method static \Database\Factories\FrontPatientTestimonialFactory
23: factory(...$parameters)
24: * @method static \Illuminate\Database\Eloquent\Builder|FrontPatientTestimonial
25: newModelQuery()
26: * @method static \Illuminate\Database\Eloquent\Builder|FrontPatientTestimonial
newQuery()
27: * @method static \Illuminate\Database\Eloquent\Builder|FrontPatientTestimonial
query()
28: * @method static \Illuminate\Database\Eloquent\Builder|FrontPatientTestimonial
29: whereCreatedAt($value)
30: * @method static \Illuminate\Database\Eloquent\Builder|FrontPatientTestimonial
31: whereDesignation($value)
32: * @method static \Illuminate\Database\Eloquent\Builder|FrontPatientTestimonial
33: whereId($value)
34: * @method static \Illuminate\Database\Eloquent\Builder|FrontPatientTestimonial
35: whereIsDefault($value)
36: * @method static \Illuminate\Database\Eloquent\Builder|FrontPatientTestimonial
37: whereName($value)
38: * @method static \Illuminate\Database\Eloquent\Builder|FrontPatientTestimonial
39: whereShortDescription($value)
40: * @method static \Illuminate\Database\Eloquent\Builder|FrontPatientTestimonial
41: whereUpdatedAt($value)
42: *
43: * @mixin Model
44: */
45: class FrontPatientTestimonial extends Model implements hasMedia
46: {
47: use HasFactory, InteractsWithMedia;
48: const FRONT_PATIENT_PROFILE = 'profile';
49: public $table = 'front_patient_testimonials';
50: public $fillable = [
51: 'name',
52: 'designation',
53: 'short_description',
54: 'is_default',
55: ];
56: protected $casts = [
57: 'name' => 'string',
58: 'designation' => 'string',
59: 'short_description' => 'string',
60: 'is_default' => 'boolean',
61: ];
62: protected $appends = ['front_patient_profile'];
63: /**
64: * Validation rules
65: *
66: * @var array
67: */
68: public static $rules = [
69: 'name' => 'required',
70: 'designation' => 'required',
71: 'short_description' => 'required|max:111',
72: 'profile' => 'required|mimes:jpeg,jpg,png|max:2000',
73: ];
74: /**
75: * Validation rules
76: *
77: * @var array
78: */
79: public static $editRules = [
80: 'name' => 'required',
81: 'designation' => 'required',
82: 'short_description' => 'required|max:111',
83: 'profile' => 'nullable|mimes:jpeg,jpg,png|max:2000',
84: ];
85: public function getFrontPatientProfileAttribute(): string
86: {
87: /** @var Media $media */
88: $media = $this->getMedia(self::FRONT_PATIENT_PROFILE)->first();
89: if (! empty($media)) {
90: return $media->getFullUrl();
91: }
92: return asset('web/media/avatars/male.png');
93: }
94: }
[app > Models > GoogleCalendarIntegration.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: /**
6: * App\Models\GoogleCalendarIntegration
7: *
8: * @property int $id
9: * @property int $user_id
10: * @property string $access_token
11: * @property mixed $meta
12: * @property string $last_used_at
13: * @property \Illuminate\Support\Carbon|null $created_at
14: * @property \Illuminate\Support\Carbon|null $updated_at
15: *
16: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarIntegration
17: newModelQuery()
18: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarIntegration
19: newQuery()
20: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarIntegration
query()
21: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarIntegration
22: whereAccessToken($value)
23: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarIntegration
24: whereCreatedAt($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarIntegration
26: whereId($value)
27: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarIntegration
28: whereLastUsedAt($value)
29: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarIntegration
30: whereMeta($value)
31: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarIntegration
32: whereUpdatedAt($value)
33: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarIntegration
34: whereUserId($value)
35: *
36: * @mixin \Eloquent
37: */
38: class GoogleCalendarIntegration extends Model
39: {
40: use HasFactory;
41: public $fillable = [
42: 'user_id',
43: 'access_token',
44: 'meta',
45: 'last_used_at',
46: ];
47: protected $casts = [
48: 'meta' => 'json',
49: ];
50: }
[app > Models > GoogleCalendarList.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: use Illuminate\Database\Eloquent\Relations\BelongsTo;
6: /**
7: * App\Models\GoogleCalendarList
8: *
9: * @property int $id
10: * @property int $user_id
11: * @property string $calendar_name
12: * @property string $google_calendar_id
13: * @property mixed $meta
14: * @property \Illuminate\Support\Carbon|null $created_at
15: * @property \Illuminate\Support\Carbon|null $updated_at
16: * @property-read \App\Models\AppointmentGoogleCalendar $appointmentGoogleCalendar
17: *
18: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarList
newModelQuery()
19: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarList newQuery()
20: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarList query()
21: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarList
22: whereCalendarName($value)
23: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarList
24: whereCreatedAt($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarList
26: whereGoogleCalendarId($value)
27: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarList
whereId($value)
28: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarList
29: whereMeta($value)
30: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarList
31: whereUpdatedAt($value)
32: * @method static \Illuminate\Database\Eloquent\Builder|GoogleCalendarList
33: whereUserId($value)
34: *
35: * @mixin \Eloquent
36: */
37: class GoogleCalendarList extends Model
38: {
39: use HasFactory;
40: public $fillable = [
41: 'user_id',
42: 'calendar_name',
43: 'google_calendar_id',
44: 'meta',
45: ];
46: protected $casts = [
47: 'user_id' => 'integer',
48: 'calendar_name' => 'string',
49: 'google_calendar_id' => 'string',
50: 'meta' => 'json',
51: ];
52: public function appointmentGoogleCalendar(): BelongsTo
53: {
54: return $this->belongsTo(AppointmentGoogleCalendar::class);
55: }
56: }
[app > Models > LiveConsultation.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: use Illuminate\Database\Eloquent\Relations\BelongsTo;
6: class LiveConsultation extends Model
7: {
8: use HasFactory;
9: /**
10: * @var string
11: */
12: protected $table = 'live_consultations';
13: const OPD = 0;
14: const IPD = 1;
15: const HOST_ENABLE = 1;
16: const HOST_DISABLED = 0;
17: const CLIENT_ENABLE = 1;
18: const CLIENT_DISABLED = 0;
19: const STATUS_AWAITED = 0;
20: const STATUS_CANCELLED = 1;
21: const STATUS_FINISHED = 2;
22: const ALL = 3;
23: const STATUS_TYPE = [
24: self::OPD => 'OPD',
25: self::IPD => 'IPD',
26: ];
27: const status = [
28: self::ALL => 'All',
29: self::STATUS_AWAITED => 'Awaited',
30: self::STATUS_CANCELLED => 'Cancelled',
31: self::STATUS_FINISHED => 'Finished',
32: ];
33: /**
34: * @var string[]
35: */
36: protected $fillable = [
37: 'doctor_id',
38: 'patient_id',
39: 'consultation_title',
40: 'consultation_date',
41: 'consultation_duration_minutes',
42: 'type',
43: 'type_number',
44: 'description',
45: 'created_by',
46: 'status',
47: 'meta',
48: 'meeting_id',
49: 'time_zone',
50: 'password',
51: 'host_video',
52: 'participant_video',
53: ];
54: /**
55: * Validation rules
56: *
57: * @var array
58: */
59: public static $rules = [
60: 'patient_id' => 'required',
61: 'doctor_id' => 'required',
62: 'consultation_title' => 'required',
63: 'consultation_date' => 'required',
64: 'consultation_duration_minutes' => 'required|numeric|min:0|max:720',
65: ];
66: /**
67: * @var string[]
68: */
69: protected $casts = [
70: 'meta' => 'array',
71: 'doctor_id' => 'integer',
72: 'patient_id' => 'integer',
73: 'consultation_title' => 'string',
74: 'consultation_date' => 'datetime',
75: 'consultation_duration_minutes' => 'string',
76: 'description' => 'string',
77: 'created_by' => 'string',
78: 'status' => 'integer',
79: 'meeting_id' => 'string',
80: 'time_zone' => 'string',
81: 'password' => 'string',
82: 'host_video' => 'boolean',
83: 'participant_video' => 'boolean',
84: ];
85: public function patient(): BelongsTo
86: {
87: return $this->belongsTo(Patient::class, 'patient_id');
88: }
89: public function doctor(): BelongsTo
90: {
91: return $this->belongsTo(Doctor::class, 'doctor_id');
92: }
93: public function user(): BelongsTo
94: {
95: return $this->belongsTo(User::class, 'created_by');
96: }
97: }
[app > Models > Medicine.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Model;
4: use Illuminate\Database\Eloquent\Relations\BelongsTo;
5: /**
6: * App\Models\Medicine
7: *
8: * @property int $id
9: * @property int|null $category_id
10: * @property int|null $brand_id
11: * @property string $name
12: * @property float $selling_price
13: * @property float $buying_price
14: * @property int $quantity
15: * @property int $available_quantity
16: * @property string $salt_composition
17: * @property string|null $description
18: * @property string|null $side_effects
19: * @property \Illuminate\Support\Carbon|null $created_at
20: * @property \Illuminate\Support\Carbon|null $updated_at
21: * @property-read \App\Models\Brand|null $brand
22: * @property-read \App\Models\Category|null $category
23: *
24: * @method static \Illuminate\Database\Eloquent\Builder|Medicine newModelQuery()
25: * @method static \Illuminate\Database\Eloquent\Builder|Medicine newQuery()
26: * @method static \Illuminate\Database\Eloquent\Builder|Medicine query()
27: * @method static \Illuminate\Database\Eloquent\Builder|Medicine
28: whereAvailableQuantity($value)
29: * @method static \Illuminate\Database\Eloquent\Builder|Medicine whereBrandId($value)
30: * @method static \Illuminate\Database\Eloquent\Builder|Medicine
whereBuyingPrice($value)
31: * @method static \Illuminate\Database\Eloquent\Builder|Medicine
whereCategoryId($value)
32: * @method static \Illuminate\Database\Eloquent\Builder|Medicine
whereCreatedAt($value)
33: * @method static \Illuminate\Database\Eloquent\Builder|Medicine
whereDescription($value)
34: * @method static \Illuminate\Database\Eloquent\Builder|Medicine whereId($value)
35: * @method static \Illuminate\Database\Eloquent\Builder|Medicine whereName($value)
36: * @method static \Illuminate\Database\Eloquent\Builder|Medicine whereQuantity($value)
37: * @method static \Illuminate\Database\Eloquent\Builder|Medicine
38: whereSaltComposition($value)
39: * @method static \Illuminate\Database\Eloquent\Builder|Medicine
whereSellingPrice($value)
40: * @method static \Illuminate\Database\Eloquent\Builder|Medicine
whereSideEffects($value)
41: * @method static \Illuminate\Database\Eloquent\Builder|Medicine
whereUpdatedAt($value)
42: *
43: * @mixin \Eloquent
44: */
45: class Medicine extends Model
46: {
47: public $table = 'medicines';
48: public $fillable = [
49: 'category_id',
50: 'brand_id',
51: 'name',
52: 'selling_price',
53: 'buying_price',
54: 'side_effects',
55: 'description',
56: 'salt_composition',
57: 'currency_symbol',
58: 'quantity',
59: 'available_quantity',
60: ];
61: /**
62: * The attributes that should be casted to native types.
63: *
64: * @var array
65: */
66: protected $casts = [
67: 'id' => 'integer',
68: 'category_id' => 'integer',
69: 'brand_id' => 'integer',
70: 'name' => 'string',
71: 'selling_price' => 'double',
72: 'buying_price' => 'double',
73: 'side_effects' => 'string',
74: 'description' => 'string',
75: 'salt_composition' => 'string',
76: 'currency_symbol' => 'string',
77: 'quantity' => 'integer',
78: 'available_quantity' => 'integer',
79: ];
80: /**
81: * Validation rules
82: *
83: * @var array
84: */
85: public static $rules = [
86: 'category_id' => 'required',
87: 'brand_id' => 'required',
88: 'name' => 'required|min:2|unique:medicines,name',
89: 'selling_price' => 'required',
90: 'buying_price' => 'required',
91: 'side_effects' => 'nullable',
92: 'salt_composition' => 'required|string',
93: // 'quantity' => 'required|integer',
94: // 'available_quantity' => 'required|integer|lte:quantity'
95: ];
96: public function category(): BelongsTo
97: {
98: return $this->belongsTo(Category::class);
99: }
100: public function brand(): BelongsTo
101: {
102: return $this->belongsTo(Brand::class);
103: }
104: public function prescriptionMedicines(): BelongsTo
105: {
106: return $this->belongsTo(PrescriptionMedicineModal::class, 'medicine');
107: }
108: public function usedMedicines(): BelongsTo
109: {
110: return $this->belongsTo(UsedMedicine::class);
111: }
112: public function purchasedMedicine(): BelongsTo
113: {
114: return $this->belongsTo(PurchasedMedicine::class);
115: }
116: }
[app > Models > MedicineBill.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Model;
4: use Illuminate\Database\Eloquent\Relations\HasMany;
5: use Illuminate\Database\Eloquent\Relations\BelongsTo;
6: use Illuminate\Database\Eloquent\Factories\HasFactory;
7: /**
8: * App\Models\MedicineBill
9: *
10: * @property int $id
11: * @property string $bill_number
12: * @property int $patient_id
13: * @property int|null $doctor_id
14: * @property string $model_type
15: * @property string $model_id
16: * @property int|null $case_id
17: * @property int $admission_id
18: * @property float $discount
19: * @property float $amount
20: * @property float $paid_amount
21: * @property int $payment_status
22: * @property float $balance_amount
23: * @property int $payment_type
24: * @property string|null $note
25: * @property \Illuminate\Support\Carbon|null $created_at
26: * @property \Illuminate\Support\Carbon|null $updated_at
27: * @property-read \App\Models\Doctor|null $doctor
28: * @property-read \App\Models\Patient|null $patient
29: * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\SaleMedicine[]
30: $saleMedicine
31: * @property-read int|null $sale_medicine_count
32: *
33: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill newModelQuery()
34: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill newQuery()
35: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill query()
36: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill
37: whereAdmissionId($value)
38: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill
whereAmount($value)
39: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill
40: whereBalanceAmount($value)
41: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill
42: whereBillNumber($value)
43: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill
whereCaseId($value)
44: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill
whereCreatedAt($value)
45: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill
whereDiscount($value)
46: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill
whereDoctorId($value)
47: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill whereId($value)
48: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill
whereModelId($value)
49: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill
whereModelType($value)
50: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill whereNote($value)
51: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill
52: wherePaidAmount($value)
53: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill
wherePatientId($value)
54: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill
55: wherePaymentStatus($value)
56: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill
57: wherePaymentType($value)
58: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill
whereUpdatedAt($value)
59: *
60: * @mixin \Eloquent
61: *
62: * @property float $net_amount
63: *
64: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill
whereNetAmount($value)
65: *
66: * @property float $total
67: * @property float $tax_amount
68: *
69: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill
whereTaxAmount($value)
70: * @method static \Illuminate\Database\Eloquent\Builder|MedicineBill
whereTotal($value)
71: */
72: class MedicineBill extends Model
73: {
74: use HasFactory;
75: protected $table = 'medicine_bills';
76: protected $fillable = [
77: 'bill_number',
78: 'patient_id',
79: 'doctor_id',
80: 'model_type',
81: 'model_id',
82: 'case_id',
83: 'admission_id',
84: 'discount',
85: 'net_amount',
86: 'payment_status',
87: 'payment_type',
88: 'note',
89: 'tax_amount',
90: 'total',
91: 'bill_date',
92: ];
93: const UNPAID = 0;
94: const FULLPAID = 1;
95: const PARTIALY_PAID = 2;
96: const PAYMENT_STATUS_ARRAY =
97: [
98: self::UNPAID => 'Unpaid',
99: self::FULLPAID => 'Full Paid',
100: self::PARTIALY_PAID => 'Partially Paid',
101: ];
102: public function patient(): BelongsTo
103: {
104: return $this->belongsTo(Patient::class, 'patient_id');
105: }
106: public function doctor(): BelongsTo
107: {
108: return $this->belongsTo(Doctor::class, 'doctor_id');
109: }
110: public function saleMedicine(): HasMany
111: {
112: return $this->hasMany(SaleMedicine::class, 'medicine_bill_id');
113: }
114: }
[app > Models > Notification.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: /**
6: * App\Models\Notification
7: *
8: * @property int $id
9: * @property string|null $title
10: * @property string|null $type
11: * @property string|null $description
12: * @property string|null $read_at
13: * @property int|null $user_id
14: * @property \Illuminate\Support\Carbon|null $created_at
15: * @property \Illuminate\Support\Carbon|null $updated_at
16: *
17: * @method static \Illuminate\Database\Eloquent\Builder|Notification newModelQuery()
18: * @method static \Illuminate\Database\Eloquent\Builder|Notification newQuery()
19: * @method static \Illuminate\Database\Eloquent\Builder|Notification query()
20: * @method static \Illuminate\Database\Eloquent\Builder|Notification
whereCreatedAt($value)
21: * @method static \Illuminate\Database\Eloquent\Builder|Notification whereId($value)
22: * @method static \Illuminate\Database\Eloquent\Builder|Notification
whereReadAt($value)
23: * @method static \Illuminate\Database\Eloquent\Builder|Notification
whereTitle($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|Notification whereType($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|Notification
whereUpdatedAt($value)
26: * @method static \Illuminate\Database\Eloquent\Builder|Notification
whereUserId($value)
27: *
28: * @mixin \Eloquent
29: */
30: class Notification extends Model
31: {
32: use HasFactory;
33: public $fillable = [
34: 'title',
35: 'type',
36: 'description',
37: 'read_at',
38: 'user_id',
39: ];
40: protected $casts = [
41: 'title' => 'string',
42: 'type' => 'string',
43: 'description' => 'string',
44: 'read_at' => 'timestamp',
45: 'user_id' => 'integer',
46: ];
47: const BOOKED = 'booked';
48: const CHECKOUT = 'checkout';
49: const CANCELED = 'canceled';
50: const PAYMENT_DONE = 'payment_done';
51: const REVIEW = 'review';
52: const LIVE_CONSULTATION = 'live_consultation';
53: const APPOINTMENT_CREATE_DOCTOR_MSG = 'booked appointment with you at';
54: const APPOINTMENT_CREATE_PATIENT_MSG = 'Your Appointment has been booked between';
55: const APPOINTMENT_CANCEL_PATIENT_MSG = 'Your Appointment has been cancelled by';
56: const APPOINTMENT_CANCEL_DOCTOR_MSG = 'cancelled appointment with you at';
57: const APPOINTMENT_PAYMENT_DONE_PATIENT_MSG = 'Your appointment payment has been
58: successful';
59: const APPOINTMENT_CHECKOUT_PATIENT_MSG = 'Your Appointment has been checkout by';
60: }
[app > Models > Patient.php]
1: <?php
2: namespace App\Models;
3: use Database\Factories\PatientFactory;
4: use Illuminate\Database\Eloquent\Factories\HasFactory;
5: use Illuminate\Database\Eloquent\Model;
6: use Illuminate\Database\Eloquent\Relations\BelongsTo;
7: use Illuminate\Database\Eloquent\Relations\HasMany;
8: use Illuminate\Database\Eloquent\Relations\MorphOne;
9: use Illuminate\Database\Query\Builder;
10: use Illuminate\Support\Carbon;
11: use Illuminate\Support\Str;
12: use Spatie\MediaLibrary\HasMedia;
13: use Spatie\MediaLibrary\InteractsWithMedia;
14: use Spatie\MediaLibrary\MediaCollections\Models\Media;
15: use Spatie\Permission\Traits\HasRoles;
16: use App\Models\SmartPatientCards;
17: /**
18: * Class Patient
19: *
20: * @version July 29, 2021, 11:37 am UTC
21: *
22: * @property int $id
23: * @property string $patient_unique_id
24: * @property int $user_id
25: * @property Carbon|null $created_at
26: * @property Carbon|null $updated_at
27: *
28: * @method static PatientFactory factory(...$parameters)
29: * @method static \Illuminate\Database\Eloquent\Builder|Patient newModelQuery()
30: * @method static \Illuminate\Database\Eloquent\Builder|Patient newQuery()
31: * @method static Builder|Patient onlyTrashed()
32: * @method static \Illuminate\Database\Eloquent\Builder|Patient query()
33: * @method static \Illuminate\Database\Eloquent\Builder|Patient whereCreatedAt($value)
34: * @method static \Illuminate\Database\Eloquent\Builder|Patient whereId($value)
35: * @method static \Illuminate\Database\Eloquent\Builder|Patient
36: wherePatientUniqueId($value)
37: * @method static \Illuminate\Database\Eloquent\Builder|Patient whereUpdatedAt($value)
38: * @method static \Illuminate\Database\Eloquent\Builder|Patient whereUserId($value)
39: * @method static Builder|Patient withTrashed()
40: * @method static Builder|Patient withoutTrashed()
41: *
42: * @mixin Model
43: *
44: * @property-read \App\Models\Address|null $address
45: * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Appointment[]
46: $appointments
47: * @property-read int|null $appointments_count
48: * @property-read string $profile
49: * @property-read
50: \Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection|Media[]
$media
51: * @property-read int|null $media_count
52: * @property-read
53: \Illuminate\Database\Eloquent\Collection|\Spatie\Permission\Models\Permission[]
54: $permissions
55: * @property-read int|null $permissions_count
56: * @property-read
\Illuminate\Database\Eloquent\Collection|\Spatie\Permission\Models\Role[]
57: $roles
58: * @property-read int|null $roles_count
59: * @property-read \App\Models\User $user
60: *
61: * @method static \Illuminate\Database\Eloquent\Builder|Patient
permission($permissions)
62: * @method static \Illuminate\Database\Eloquent\Builder|Patient role($roles, $guard =
null)
63: */
64: class Patient extends Model implements HasMedia
65: {
66: use HasFactory, InteractsWithMedia, HasRoles;
67: protected $table = 'patients';
68: const PROFILE = 'profile';
69: const O_POSITIVE = 1;
70: const A_POSITIVE = 2;
71: const B_POSITIVE = 3;
72: const AB_POSITIVE = 4;
73: const O_NEGATIVE = 5;
74: const A_NEGATIVE = 6;
75: const B_NEGATIVE = 7;
76: const AB_NEGATIVE = 8;
77: const BLOOD_GROUP_ARRAY = [
78: self::O_POSITIVE => 'O+',
79: self::A_POSITIVE => 'A+',
80: self::B_POSITIVE => 'B+',
81: self::AB_POSITIVE => 'AB+',
82: self::O_NEGATIVE => 'O-',
83: self::A_NEGATIVE => 'A-',
84: self::B_NEGATIVE => 'B-',
85: self::AB_NEGATIVE => 'AB-',
86: ];
87: const MALE = 1;
88: const FEMALE = 2;
89: const ALL_PATIENT = 1;
90: const ONLY_ONE_PATIENT = 2;
91: const REMANING_PATIENT = 3;
92: const ALL = 1;
93: const TODAY = 2;
94: const WEEK = 3;
95: const MONTH = 4;
96: const YEAR = 5;
97: const PATIENT_FILTER = [
98: self::ALL => 'All',
99: self::TODAY => 'Today',
100: self::WEEK => 'This Week',
101: self::MONTH => 'This Month',
102: self::YEAR => 'This Year',
103: ];
104: const STATUS = [
105: self::ALL_PATIENT => 'All',
106: self::ONLY_ONE_PATIENT => 'Active',
107: self::REMANING_PATIENT => 'Deactive',
108: ];
109: public $fillable = [
110: 'patient_unique_id',
111: 'user_id',
112: ];
113: protected $casts = [
114: 'patient_unique_id' => 'string',
115: 'user_id' => 'integer',
116: ];
117: /**
118: * Validation rules
119: *
120: * @var array
121: */
122: public static $rules = [
123: 'patient_unique_id' => 'required|unique:patients,patient_unique_id|regex:/^\S*$/u',
124: 'first_name' => 'required',
125: 'last_name' => 'required',
126: 'email' => 'required|email|unique:users,email',
127: 'contact' => 'nullable|unique:users,contact',
128: 'password' => 'required|same:password_confirmation|min:6',
129: 'postal_code' => 'nullable',
130: 'profile' => 'nullable|mimes:jpeg,jpg,png|max:2000',
131: ];
132: /**
133: * Validation rules
134: *
135: * @var array
136: */
137: public static $editRules = [
138: 'first_name' => 'required',
139: 'last_name' => 'required',
140: 'profile' => 'nullable|mimes:jpeg,jpg,png',
141: ];
142: protected $appends = ['profile'];
143: protected $with = ['media'];
144: public static function generatePatientUniqueId(): string
145: {
146: $patientUniqueId = Str::random(8);
147: while (true) {
148: $isExist = self::wherePatientUniqueId($patientUniqueId)->exists();
149: if ($isExist) {
150: self::generatePatientUniqueId();
151: }
152: break;
153: }
154: return $patientUniqueId;
155: }
156: public function getProfileAttribute(): string
157: {
158: /** @var Media $media */
159: $media = $this->getMedia(self::PROFILE)->first();
160: if (! empty($media)) {
161: return $media->getFullUrl();
162: }
163: $gender = $this->user->gender;
164: if ($gender == self::FEMALE) {
165: return asset('web/media/avatars/female.png');
166: }
167: return asset('web/media/avatars/male.png');
168: }
169: public function address(): MorphOne
170: {
171: return $this->morphOne(Address::class, 'owner');
172: }
173: public function user(): BelongsTo
174: {
175: return $this->belongsTo(User::class, 'user_id');
176: }
177: public function patientUser(): BelongsTo
178: {
179: return $this->belongsTo(User::class, 'user_id');
180: }
181: public function smartPatientCard(): BelongsTo
182: {
183: return $this->belongsTo(SmartPatientCards::class, 'template_id');
184: }
185: public function appointments(): HasMany
186: {
187: return $this->hasMany(Appointment::class, 'patient_id');
188: }
189: public function reviews(): HasMany
190: {
191: return $this->hasMany(Review::class);
192: }
193: }
[app > Models > PaymentGateway.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: /**
6: * App\Models\PaymentGateway
7: *
8: * @property int $id
9: * @property int $payment_gateway_id
10: * @property string $payment_gateway
11: * @property \Illuminate\Support\Carbon|null $created_at
12: * @property \Illuminate\Support\Carbon|null $updated_at
13: *
14: * @method static \Illuminate\Database\Eloquent\Builder|PaymentGateway newModelQuery()
15: * @method static \Illuminate\Database\Eloquent\Builder|PaymentGateway newQuery()
16: * @method static \Illuminate\Database\Eloquent\Builder|PaymentGateway query()
17: * @method static \Illuminate\Database\Eloquent\Builder|PaymentGateway
18: whereCreatedAt($value)
19: * @method static \Illuminate\Database\Eloquent\Builder|PaymentGateway whereId($value)
20: * @method static \Illuminate\Database\Eloquent\Builder|PaymentGateway
21: wherePaymentGateway($value)
22: * @method static \Illuminate\Database\Eloquent\Builder|PaymentGateway
23: wherePaymentGatewayId($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|PaymentGateway
25: whereUpdatedAt($value)
26: *
27: * @mixin \Eloquent
28: */
29: class PaymentGateway extends Model
30: {
31: use HasFactory;
32: protected $table = 'payment_gateways';
33: protected $fillable = [
34: 'payment_gateway_id',
35: 'payment_gateway',
36: ];
37: protected $casts = [
38: 'payment_gateway_id' => 'integer',
39: 'payment_gateway' => 'string',
40: ];
41: }
[app > Models > Permission.php]
1: <?php
2: namespace App\Models;
3: use Eloquent as Model;
4: use Illuminate\Database\Eloquent\Factories\HasFactory;
5: use Illuminate\Support\Carbon;
6: /**
7: * Class Role
8: *
9: * @version August 5, 2021, 10:43 am UTC
10: *
11: * @property string $name
12: * @property int $id
13: * @property string $display_name
14: * @property string $guard_name
15: * @property Carbon|null $created_at
16: * @property Carbon|null $updated_at
17: *
18: * @method static \Illuminate\Database\Eloquent\Builder|Permission newModelQuery()
19: * @method static \Illuminate\Database\Eloquent\Builder|Permission newQuery()
20: * @method static \Illuminate\Database\Eloquent\Builder|Permission query()
21: * @method static \Illuminate\Database\Eloquent\Builder|Permission
whereCreatedAt($value)
22: * @method static \Illuminate\Database\Eloquent\Builder|Permission
whereDisplayName($value)
23: * @method static \Illuminate\Database\Eloquent\Builder|Permission
whereGuardName($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|Permission whereId($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|Permission whereName($value)
26: * @method static \Illuminate\Database\Eloquent\Builder|Permission
whereUpdatedAt($value)
27: *
28: * @mixin Model
29: */
30: class Permission extends Model
31: {
32: use HasFactory;
33: protected $table = 'permissions';
34: public $fillable = [
35: 'name', 'display_name', 'guard_name',
36: ];
37: /**
38: * The attributes that should be casted to native types.
39: *
40: * @var array
41: */
42: protected $casts = [
43: 'name' => 'string',
44: 'display_name' => 'string',
45: 'guard_name' => 'string',
46: ];
47: }
[app > Models > Prescription.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Model;
4: use Illuminate\Database\Eloquent\Relations\HasMany;
5: use Illuminate\Database\Eloquent\Relations\BelongsTo;
6: /**
7: * App\Models\Prescription
8: *
9: * @property int $id
10: * @property int $appointment_id
11: * @property int $patient_id
12: * @property int|null $doctor_id
13: * @property string|null $food_allergies
14: * @property string|null $tendency_bleed
15: * @property string|null $heart_disease
16: * @property string|null $high_blood_pressure
17: * @property string|null $diabetic
18: * @property string|null $surgery
19: * @property string|null $accident
20: * @property string|null $others
21: * @property string|null $medical_history
22: * @property string|null $current_medication
23: * @property string|null $female_pregnancy
24: * @property string|null $breast_feeding
25: * @property string|null $health_insurance
26: * @property string|null $low_income
27: * @property string|null $reference
28: * @property bool|null $status
29: * @property string|null $plus_rate
30: * @property string|null $temperature
31: * @property string|null $problem_description
32: * @property string|null $test
33: * @property string|null $advice
34: * @property \Illuminate\Support\Carbon|null $created_at
35: * @property \Illuminate\Support\Carbon|null $updated_at
36: * @property-read \App\Models\Doctor|null $doctor
37: * @property-read \App\Models\Patient $patient
38: *
39: * @method static \Illuminate\Database\Eloquent\Builder|Prescription newModelQuery()
40: * @method static \Illuminate\Database\Eloquent\Builder|Prescription newQuery()
41: * @method static \Illuminate\Database\Eloquent\Builder|Prescription query()
42: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
whereAccident($value)
43: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
whereAdvice($value)
44: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
45: whereAppointmentId($value)
46: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
47: whereBreastFeeding($value)
48: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
whereCreatedAt($value)
49: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
50: whereCurrentMedication($value)
51: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
whereDiabetic($value)
52: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
whereDoctorId($value)
53: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
54: whereFemalePregnancy($value)
55: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
56: whereFoodAllergies($value)
57: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
58: whereHealthInsurance($value)
59: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
60: whereHeartDisease($value)
61: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
62: whereHighBloodPressure($value)
63: * @method static \Illuminate\Database\Eloquent\Builder|Prescription whereId($value)
64: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
whereLowIncome($value)
65: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
66: whereMedicalHistory($value)
67: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
whereOthers($value)
68: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
wherePatientId($value)
69: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
wherePlusRate($value)
70: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
71: whereProblemDescription($value)
72: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
whereReference($value)
73: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
whereStatus($value)
74: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
whereSurgery($value)
75: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
76: whereTemperature($value)
77: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
78: whereTendencyBleed($value)
79: * @method static \Illuminate\Database\Eloquent\Builder|Prescription whereTest($value)
80: * @method static \Illuminate\Database\Eloquent\Builder|Prescription
whereUpdatedAt($value)
81: *
82: * @mixin \Eloquent
83: */
84: class Prescription extends Model
85: {
86: public $table = 'prescriptions';
87: public $fillable = [
88: 'patient_id',
89: 'doctor_id',
90: 'food_allergies',
91: 'tendency_bleed',
92: 'heart_disease',
93: 'high_blood_pressure',
94: 'diabetic',
95: 'surgery',
96: 'accident',
97: 'others',
98: 'medical_history',
99: 'current_medication',
100: 'female_pregnancy',
101: 'breast_feeding',
102: 'health_insurance',
103: 'low_income',
104: 'reference',
105: 'status',
106: 'plus_rate',
107: 'temperature',
108: 'problem_description',
109: 'test',
110: 'advice',
111: 'appointment_id',
112: ];
113: /**
114: * The attributes that should be casted to native types.
115: *
116: * @var array
117: */
118: protected $casts = [
119: 'id' => 'integer',
120: 'patient_id' => 'integer',
121: 'appointment_id' => 'integer',
122: 'food_allergies' => 'string',
123: 'tendency_bleed' => 'string',
124: 'heart_disease' => 'string',
125: 'high_blood_pressure' => 'string',
126: 'diabetic' => 'string',
127: 'surgery' => 'string',
128: 'accident' => 'string',
129: 'others' => 'string',
130: 'medical_history' => 'string',
131: 'current_medication' => 'string',
132: 'female_pregnancy' => 'string',
133: 'breast_feeding' => 'string',
134: 'health_insurance' => 'string',
135: 'low_income' => 'string',
136: 'reference' => 'string',
137: 'status' => 'boolean',
138: 'plus_rate' => 'string',
139: 'temperature' => 'string',
140: 'problem_description' => 'string',
141: 'test' => 'string',
142: 'advice' => 'string',
143: ];
144: /**
145: * Validation rules
146: *
147: * @var array
148: */
149: public static $rules = [
150: 'patient_id' => 'required',
151: ];
152: const STATUS_ALL = 2;
153: const ACTIVE = 1;
154: const INACTIVE = 0;
155: const STATUS_ARR = [
156: self::STATUS_ALL => 'All',
157: self::ACTIVE => 'Active',
158: self::INACTIVE => 'Deactive',
159: ];
160: const DAYS = 0;
161: const MONTH = 1;
162: const YEAR = 2;
163: const TIME_ARR = [
164: self::DAYS => 'Days',
165: self::MONTH => 'Month',
166: self::YEAR => 'Years',
167: ];
168: const AFETR_MEAL = 0;
169: const BEFORE_MEAL = 1;
170: const MEAL_ARR = [
171: self::AFETR_MEAL => 'After Meal',
172: self::BEFORE_MEAL => 'Before Meal',
173: ];
174: const ONE_TIME = 1;
175: const TWO_TIME = 2;
176: const THREE_TIME = 3;
177: const FOUR_TIME = 4;
178: const DOSE_INTERVAL = [
179: self::ONE_TIME => 'Every Morning',
180: self::TWO_TIME => 'Every Morning & Evening',
181: self::THREE_TIME => 'Three times a day',
182: self::FOUR_TIME => '4 times a day',
183: ];
184: const ONE_DAY = 1;
185: const THREE_DAY = 3;
186: const ONE_WEEK = 7;
187: const TWO_WEEK = 14;
188: const ONE_MONTH = 30;
189: const DOSE_DURATION = [
190: self::ONE_DAY => 'One day only',
191: self::THREE_DAY => 'For Three days',
192: self::ONE_WEEK => 'For One week',
193: self::TWO_WEEK => 'For 2 weeks',
194: self::ONE_MONTH => 'For 1 Month',
195: ];
196: public function patient(): BelongsTo
197: {
198: return $this->belongsTo(Patient::class, 'patient_id');
199: }
200: public function doctor(): BelongsTo
201: {
202: return $this->belongsTo(Doctor::class, 'doctor_id');
203: }
204: public function getMedicine(): HasMany
205: {
206: return $this->hasMany(PrescriptionMedicineModal::class);
207: }
208: }
[app > Models > PrescriptionMedicineModal.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: /**
6: * App\Models\PrescriptionMedicineModal
7: *
8: * @property int $id
9: * @property int $prescription_id
10: * @property int $medicine
11: * @property string|null $dosage
12: * @property string|null $day
13: * @property string|null $time
14: * @property string|null $comment
15: * @property \Illuminate\Support\Carbon|null $created_at
16: * @property \Illuminate\Support\Carbon|null $updated_at
17: * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Medicine[]
18: $medicines
19: * @property-read int|null $medicines_count
20: * @property-read \App\Models\Prescription $prescription
21: *
22: * @method static \Illuminate\Database\Eloquent\Builder|PrescriptionMedicineModal
23: newModelQuery()
24: * @method static \Illuminate\Database\Eloquent\Builder|PrescriptionMedicineModal
25: newQuery()
26: * @method static \Illuminate\Database\Eloquent\Builder|PrescriptionMedicineModal
query()
27: * @method static \Illuminate\Database\Eloquent\Builder|PrescriptionMedicineModal
28: whereComment($value)
29: * @method static \Illuminate\Database\Eloquent\Builder|PrescriptionMedicineModal
30: whereCreatedAt($value)
31: * @method static \Illuminate\Database\Eloquent\Builder|PrescriptionMedicineModal
32: whereDay($value)
33: * @method static \Illuminate\Database\Eloquent\Builder|PrescriptionMedicineModal
34: whereDosage($value)
35: * @method static \Illuminate\Database\Eloquent\Builder|PrescriptionMedicineModal
36: whereId($value)
37: * @method static \Illuminate\Database\Eloquent\Builder|PrescriptionMedicineModal
38: whereMedicine($value)
39: * @method static \Illuminate\Database\Eloquent\Builder|PrescriptionMedicineModal
40: wherePrescriptionId($value)
41: * @method static \Illuminate\Database\Eloquent\Builder|PrescriptionMedicineModal
42: whereTime($value)
43: * @method static \Illuminate\Database\Eloquent\Builder|PrescriptionMedicineModal
44: whereUpdatedAt($value)
45: *
46: * @mixin \Eloquent
47: */
48: class PrescriptionMedicineModal extends Model
49: {
50: use HasFactory;
51: public $table = 'prescriptions_medicines';
52: public $fillable = [
53: 'id',
54: 'prescription_id',
55: 'medicine',
56: 'dosage',
57: 'day',
58: 'time',
59: 'dose_interval',
60: 'comment',
61: ];
62: /**
63: * The attributes that should be casted to native types.
64: *
65: * @var array
66: */
67: protected $casts = [
68: 'prescription_id' => 'integer',
69: 'medicine' => 'integer',
70: 'dosage' => 'string',
71: 'day' => 'string',
72: 'time' => 'string',
73: 'comment' => 'string',
74: ];
75: /**
76: * Validation rules
77: *
78: * @var array
79: */
80: public static $rules = [
81: ];
82: public function prescription(): \Illuminate\Database\Eloquent\Relations\BelongsTo
83: {
84: return $this->belongsTo(Prescription::class, 'prescription_id');
85: }
86: public function medicines(): \Illuminate\Database\Eloquent\Relations\HasMany
87: {
88: return $this->hasMany(Medicine::class, 'id', 'medicine');
89: }
90: }
[app > Models > PurchasedMedicine.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Model;
4: use Illuminate\Database\Eloquent\Relations\BelongsTo;
5: /**
6: * App\Models\PurchasedMedicine
7: *
8: * @property int $id
9: * @property int $purchase_medicines_id
10: * @property int|null $medicine_id
11: * @property string|null $expiry_date
12: * @property string $lot_no
13: * @property float $tax
14: * @property int $quantity
15: * @property float $amount
16: * @property \Illuminate\Support\Carbon|null $created_at
17: * @property \Illuminate\Support\Carbon|null $updated_at
18: * @property-read \App\Models\Medicine|null $medicines
19: *
20: * @method static \Illuminate\Database\Eloquent\Builder|PurchasedMedicine
newModelQuery()
21: * @method static \Illuminate\Database\Eloquent\Builder|PurchasedMedicine newQuery()
22: * @method static \Illuminate\Database\Eloquent\Builder|PurchasedMedicine query()
23: * @method static \Illuminate\Database\Eloquent\Builder|PurchasedMedicine
24: whereAmount($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|PurchasedMedicine
26: whereCreatedAt($value)
27: * @method static \Illuminate\Database\Eloquent\Builder|PurchasedMedicine
28: whereExpiryDate($value)
29: * @method static \Illuminate\Database\Eloquent\Builder|PurchasedMedicine
whereId($value)
30: * @method static \Illuminate\Database\Eloquent\Builder|PurchasedMedicine
31: whereLotNo($value)
32: * @method static \Illuminate\Database\Eloquent\Builder|PurchasedMedicine
33: whereMedicineId($value)
34: * @method static \Illuminate\Database\Eloquent\Builder|PurchasedMedicine
35: wherePurchaseMedicinesId($value)
36: * @method static \Illuminate\Database\Eloquent\Builder|PurchasedMedicine
37: whereQuantity($value)
38: * @method static \Illuminate\Database\Eloquent\Builder|PurchasedMedicine
whereTax($value)
39: * @method static \Illuminate\Database\Eloquent\Builder|PurchasedMedicine
40: whereUpdatedAt($value)
41: *
42: * @mixin \Eloquent
43: */
44: class PurchasedMedicine extends Model
45: {
46: protected $fillable =
47: [
48: 'purchase_medicines_id',
49: 'medicine_id',
50: 'lot_no',
51: 'expiry_date',
52: 'quantity',
53: 'amount',
54: 'tax',
55: 'tenant_id',
56: ];
57: public function medicines(): BelongsTo
58: {
59: return $this->belongsTo(Medicine::class, 'medicine_id');
60: }
61: }
[app > Models > PurchaseMedicine.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Model;
4: use Illuminate\Database\Eloquent\Relations\HasMany;
5: class PurchaseMedicine extends Model
6: {
7: protected $fillable =
8: [
9: 'purchase_no',
10: 'total',
11: 'discount',
12: 'tax',
13: 'net_amount',
14: 'payment_type',
15: 'payment_note',
16: 'note',
17: 'tenant_id',
18: ];
19: const CASH = 0;
20: const CHEQUE = 1;
21: const OTHER = 2;
22: const PAYMENT_METHOD = [
23: self::CASH => 'Cash',
24: self::CHEQUE => 'Cheque',
25: self::OTHER => 'Other',
26: ];
27: public function purchasedMedcines(): HasMany
28: {
29: return $this->hasMany(PurchasedMedicine::class, 'purchase_medicines_id');
30: }
31: }
[app > Models > Qualification.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Model;
4: use Illuminate\Support\Carbon;
5: /**
6: * App\Models\Qualification
7: *
8: * @property int $id
9: * @property int $user_id
10: * @property string|null $degree
11: * @property string|null $university
12: * @property string|null $year
13: * @property Carbon|null $created_at
14: * @property Carbon|null $updated_at
15: *
16: * @method static \Illuminate\Database\Eloquent\Builder|Qualification newModelQuery()
17: * @method static \Illuminate\Database\Eloquent\Builder|Qualification newQuery()
18: * @method static \Illuminate\Database\Eloquent\Builder|Qualification query()
19: * @method static \Illuminate\Database\Eloquent\Builder|Qualification
20: whereCreatedAt($value)
21: * @method static \Illuminate\Database\Eloquent\Builder|Qualification
whereDegree($value)
22: * @method static \Illuminate\Database\Eloquent\Builder|Qualification whereId($value)
23: * @method static \Illuminate\Database\Eloquent\Builder|Qualification
24: whereUniversity($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|Qualification
26: whereUpdatedAt($value)
27: * @method static \Illuminate\Database\Eloquent\Builder|Qualification
whereUserId($value)
28: * @method static \Illuminate\Database\Eloquent\Builder|Qualification
whereYear($value)
29: *
30: * @mixin \Eloquent
31: */
32: class Qualification extends Model
33: {
34: /**
35: * @var string
36: */
37: protected $table = 'qualifications';
38: /**
39: * @var string[]
40: */
41: protected $fillable = [
42: 'user_id',
43: 'degree',
44: 'university',
45: 'year',
46: ];
47: protected $casts = [
48: 'user_id' => 'integer',
49: 'degree' => 'string',
50: 'university' => 'string',
51: 'year' => 'string',
52: ];
53: /**
54: * Validation rules
55: *
56: * @var array
57: */
58: public static $rules = [
59: 'degree' => 'required',
60: 'university' => 'required',
61: 'year' => 'required',
62: ];
63: }
[app > Models > Review.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: use Illuminate\Database\Eloquent\Relations\BelongsTo;
6: /**
7: * App\Models\Review
8: *
9: * @property int $id
10: * @property int $patient_id
11: * @property int $doctor_id
12: * @property string $review
13: * @property int $rating
14: * @property \Illuminate\Support\Carbon|null $created_at
15: * @property \Illuminate\Support\Carbon|null $updated_at
16: *
17: * @method static \Illuminate\Database\Eloquent\Builder|Review newModelQuery()
18: * @method static \Illuminate\Database\Eloquent\Builder|Review newQuery()
19: * @method static \Illuminate\Database\Eloquent\Builder|Review query()
20: * @method static \Illuminate\Database\Eloquent\Builder|Review whereCreatedAt($value)
21: * @method static \Illuminate\Database\Eloquent\Builder|Review whereDoctorId($value)
22: * @method static \Illuminate\Database\Eloquent\Builder|Review whereId($value)
23: * @method static \Illuminate\Database\Eloquent\Builder|Review wherePatientId($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|Review whereRating($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|Review whereReview($value)
26: * @method static \Illuminate\Database\Eloquent\Builder|Review whereUpdatedAt($value)
27: *
28: * @mixin \Eloquent
29: */
30: class Review extends Model
31: {
32: use HasFactory;
33: public $fillable = [
34: 'patient_id',
35: 'doctor_id',
36: 'review',
37: 'rating',
38: ];
39: protected $casts = [
40: 'patient_id' => 'integer',
41: 'doctor_id' => 'integer',
42: 'review' => 'string',
43: 'rating' => 'integer',
44: ];
45: const STAR_RATING_1 = 1;
46: const STAR_RATING_2 = 2;
47: const STAR_RATING_3 = 3;
48: const STAR_RATING_4 = 4;
49: const STAR_RATING_5 = 5;
50: /**
51: * Validation rules
52: *
53: * @var array
54: */
55: public static $rules = [
56: 'doctor_id' => 'required',
57: 'review' => 'required|max:121',
58: 'rating' => 'required',
59: ];
60: public function doctor(): BelongsTo
61: {
62: return $this->belongsTo(Doctor::class, 'doctor_id');
63: }
64: public function patient(): BelongsTo
65: {
66: return $this->belongsTo(Patient::class, 'patient_id');
67: }
68: }
[app > Models > Role.php]
1: <?php
2: namespace App\Models;
3: use Database\Factories\RoleFactory;
4: use Eloquent as Model;
5: use Illuminate\Database\Eloquent\Builder;
6: use Illuminate\Database\Eloquent\Collection;
7: use Illuminate\Database\Eloquent\Factories\HasFactory;
8: use Illuminate\Support\Carbon;
9: use Spatie\Permission\Models\Role as roleModal;
10: /**
11: * Class Role
12: *
13: * @version August 5, 2021, 10:43 am UTC
14: *
15: * @property string $name
16: * @property int $id
17: * @property string $display_name
18: * @property int $is_default
19: * @property string $guard_name
20: * @property Carbon|null $created_at
21: * @property Carbon|null $updated_at
22: * @property-read Collection|\Spatie\Permission\Models\Permission[] $permissions
23: * @property-read int|null $permissions_count
24: * @property-read Collection|User[] $users
25: * @property-read int|null $users_count
26: *
27: * @method static RoleFactory factory(...$parameters)
28: * @method static Builder|Role newModelQuery()
29: * @method static Builder|Role newQuery()
30: * @method static Builder|Role permission($permissions)
31: * @method static Builder|Role query()
32: * @method static Builder|Role whereCreatedAt($value)
33: * @method static Builder|Role whereDisplayName($value)
34: * @method static Builder|Role whereGuardName($value)
35: * @method static Builder|Role whereId($value)
36: * @method static Builder|Role whereIsDefault($value)
37: * @method static Builder|Role whereName($value)
38: * @method static Builder|Role whereUpdatedAt($value)
39: *
40: * @mixin Model
41: */
42: class Role extends roleModal
43: {
44: use HasFactory;
45: protected $table = 'roles';
46: public static $rules = [
47: 'display_name' => 'required|unique:roles,display_name',
48: 'permission_id' => 'required',
49: ];
50: }
[app > Models > SaleMedicine.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Model;
4: use Illuminate\Database\Eloquent\Relations\BelongsTo;
5: use Illuminate\Database\Eloquent\Factories\HasFactory;
6: /**
7: * App\Models\SaleMedicine
8: *
9: * @property int $id
10: * @property int $medicine_bill_id
11: * @property int $medicine_id
12: * @property int $sale_quantity
13: * @property float $tax
14: * @property float $amount
15: * @property \Illuminate\Support\Carbon|null $created_at
16: * @property \Illuminate\Support\Carbon|null $updated_at
17: * @property-read \App\Models\Medicine|null $medicine
18: * @property-read \App\Models\MedicineBill|null $medicineBill
19: *
20: * @method static \Illuminate\Database\Eloquent\Builder|SaleMedicine newModelQuery()
21: * @method static \Illuminate\Database\Eloquent\Builder|SaleMedicine newQuery()
22: * @method static \Illuminate\Database\Eloquent\Builder|SaleMedicine query()
23: * @method static \Illuminate\Database\Eloquent\Builder|SaleMedicine
whereAmount($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|SaleMedicine
whereCreatedAt($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|SaleMedicine whereId($value)
26: * @method static \Illuminate\Database\Eloquent\Builder|SaleMedicine
27: whereMedicineBillId($value)
28: * @method static \Illuminate\Database\Eloquent\Builder|SaleMedicine
29: whereMedicineId($value)
30: * @method static \Illuminate\Database\Eloquent\Builder|SaleMedicine
31: whereSaleQuantity($value)
32: * @method static \Illuminate\Database\Eloquent\Builder|SaleMedicine whereTax($value)
33: * @method static \Illuminate\Database\Eloquent\Builder|SaleMedicine
whereUpdatedAt($value)
34: *
35: * @mixin \Eloquent
36: */
37: class SaleMedicine extends Model
38: {
39: use HasFactory;
40: protected $table = 'sale_medicines';
41: protected $fillable = [
42: 'medicine_bill_id',
43: 'medicine_id',
44: 'sale_quantity',
45: 'sale_price',
46: 'tax',
47: ];
48: public function medicine(): BelongsTo
49: {
50: return $this->belongsTo(Medicine::class);
51: }
52: public function medicineBill(): BelongsTo
53: {
54: return $this->belongsTo(MedicineBill::class, 'medicine_bill_id');
55: }
56: }
[app > Models > Service.php]
1: <?php
2: namespace App\Models;
3: use Database\Factories\ServicesFactory;
4: use Illuminate\Database\Eloquent\Builder;
5: use Illuminate\Database\Eloquent\Collection;
6: use Illuminate\Database\Eloquent\Factories\HasFactory;
7: use Illuminate\Database\Eloquent\Model;
8: use Illuminate\Database\Eloquent\Relations\BelongsTo;
9: use Illuminate\Database\Eloquent\Relations\BelongsToMany;
10: use Illuminate\Support\Carbon;
11: use Spatie\MediaLibrary\HasMedia;
12: use Spatie\MediaLibrary\InteractsWithMedia;
13: /**
14: * Class Services
15: *
16: * @version August 2, 2021, 12:09 pm UTC
17: *
18: * @property string $category
19: * @property string $name
20: * @property string $charges
21: * @property string $doctors
22: * @property sting $status
23: * @property int $id
24: * @property Carbon|null $created_at
25: * @property Carbon|null $updated_at
26: *
27: * @method static ServicesFactory factory(...$parameters)
28: * @method static Builder|Service newModelQuery()
29: * @method static Builder|Service newQuery()
30: * @method static Builder|Service query()
31: * @method static Builder|Service whereCategory($value)
32: * @method static Builder|Service whereCharges($value)
33: * @method static Builder|Service whereCreatedAt($value)
34: * @method static Builder|Service whereDoctors($value)
35: * @method static Builder|Service whereId($value)
36: * @method static Builder|Service whereName($value)
37: * @method static Builder|Service whereStatus($value)
38: * @method static Builder|Service whereUpdatedAt($value)
39: *
40: * @mixin Model
41: *
42: * @property string $category_id
43: * @property-read ServiceCategory $serviceCategory
44: * @property-read Collection|\App\Models\Doctor[] $serviceDoctors
45: * @property-read int|null $service_doctors_count
46: *
47: * @method static Builder|Service whereCategoryId($value)
48: */
49: class Service extends Model implements HasMedia
50: {
51: use HasFactory, InteractsWithMedia;
52: protected $table = 'services';
53: public $fillable = [
54: 'category_id',
55: 'name',
56: 'charges',
57: 'status',
58: 'short_description',
59: ];
60: const ALL = 2;
61: const ACTIVE = 1;
62: const DEACTIVE = 0;
63: const STATUS = [
64: self::ALL => 'All',
65: self::ACTIVE => 'Active',
66: self::DEACTIVE => 'Deactive',
67: ];
68: const ICON = 'icon';
69: protected $appends = ['icon'];
70: /**
71: * The attributes that should be casted to native types.
72: *
73: * @var array
74: */
75: protected $casts = [
76: 'category_id' => 'integer',
77: 'name' => 'string',
78: 'charges' => 'string',
79: 'status' => 'boolean',
80: 'short_description' => 'string',
81: ];
82: /**
83: * Validation rules
84: *
85: * @var array
86: */
87: public static $rules = [
88: 'name' => 'required|unique:services,name',
89: 'category_id' => 'required',
90: 'charges' => 'required|min:0|not_in:0',
91: 'doctors' => 'required',
92: 'short_description' => 'required|max:60',
93: 'icon' => 'required|mimes:svg,jpeg,png,jpg',
94: ];
95: public function serviceDoctors(): BelongsToMany
96: {
97: return $this->belongsToMany(Doctor::class, 'service_doctor', 'service_id',
'doctor_id');
98: }
99: public function serviceCategory(): BelongsTo
100: {
101: return $this->belongsTo(ServiceCategory::class, 'category_id', 'id');
102: }
103: public function getIconAttribute(): string
104: {
105: /** @var Media $media */
106: $media = $this->getMedia(self::ICON)->first();
107: if (! empty($media)) {
108: return $media->getFullUrl();
109: }
110: return asset('web/media/avatars/male.png');
111: }
112: }
[app > Models > ServiceCategory.php]
1: <?php
2: namespace App\Models;
3: use Database\Factories\ServiceCategoryFactory;
4: use Illuminate\Database\Eloquent\Builder;
5: use Illuminate\Database\Eloquent\Factories\HasFactory;
6: use Illuminate\Database\Eloquent\Model;
7: use Illuminate\Support\Carbon;
8: /**
9: * Class ServiceCategory
10: *
11: * @version August 2, 2021, 7:11 am UTC
12: *
13: * @property string $name
14: * @property int $id
15: * @property Carbon|null $created_at
16: * @property Carbon|null $updated_at
17: *
18: * @method static ServiceCategoryFactory factory(...$parameters)
19: * @method static Builder|ServiceCategory newModelQuery()
20: * @method static Builder|ServiceCategory newQuery()
21: * @method static Builder|ServiceCategory query()
22: * @method static Builder|ServiceCategory whereCreatedAt($value)
23: * @method static Builder|ServiceCategory whereId($value)
24: * @method static Builder|ServiceCategory whereName($value)
25: * @method static Builder|ServiceCategory whereUpdatedAt($value)
26: *
27: * @mixin Model
28: */
29: class ServiceCategory extends Model
30: {
31: use HasFactory;
32: protected $table = 'service_categories';
33: public $fillable = [
34: 'name',
35: ];
36: /**
37: * The attributes that should be casted to native types.
38: *
39: * @var array
40: */
41: protected $casts = [
42: 'name' => 'string',
43: ];
44: /**
45: * Validation rules
46: *
47: * @var array
48: */
49: public static $rules = [
50: 'name' => 'required|unique:service_categories,name',
51: ];
52: public function services(): \Illuminate\Database\Eloquent\Relations\HasMany
53: {
54: return $this->hasMany(Service::class, 'category_id');
55: }
56: public function activatedServices(): \Illuminate\Database\Eloquent\Relations\HasMany
57: {
58: return $this->hasMany(Service::class, 'category_id')->where('status',
Service::ACTIVE);
59: }
60: }
[app > Models > Setting.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: use Spatie\MediaLibrary\HasMedia;
6: use Spatie\MediaLibrary\InteractsWithMedia;
7: use Spatie\Permission\Traits\HasRoles;
8: /**
9: * App\Models\Setting
10: *
11: * @property int $id
12: * @property string $key
13: * @property string $value
14: * @property \Illuminate\Support\Carbon|null $created_at
15: * @property \Illuminate\Support\Carbon|null $updated_at
16: *
17: * @method static \Illuminate\Database\Eloquent\Builder|Setting newModelQuery()
18: * @method static \Illuminate\Database\Eloquent\Builder|Setting newQuery()
19: * @method static \Illuminate\Database\Eloquent\Builder|Setting query()
20: * @method static \Illuminate\Database\Eloquent\Builder|Setting whereCreatedAt($value)
21: * @method static \Illuminate\Database\Eloquent\Builder|Setting whereId($value)
22: * @method static \Illuminate\Database\Eloquent\Builder|Setting whereKey($value)
23: * @method static \Illuminate\Database\Eloquent\Builder|Setting whereUpdatedAt($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|Setting whereValue($value)
25: *
26: * @mixin \Eloquent
27: *
28: * @property-read \App\Models\Country $country
29: * @property-read
30: \Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection|\Spatie\Medi
aLibrary\MediaCollections\Models\Media[]
31: $media
32: * @property-read int|null $media_count
33: * @property-read
34: \Illuminate\Database\Eloquent\Collection|\Spatie\Permission\Models\Permission[]
35: $permissions
36: * @property-read int|null $permissions_count
37: * @property-read
\Illuminate\Database\Eloquent\Collection|\Spatie\Permission\Models\Role[]
38: $roles
39: * @property-read int|null $roles_count
40: *
41: * @method static \Illuminate\Database\Eloquent\Builder|Setting
permission($permissions)
42: * @method static \Illuminate\Database\Eloquent\Builder|Setting role($roles, $guard =
null)
43: */
44: class Setting extends Model implements HasMedia
45: {
46: use HasFactory, InteractsWithMedia, HasRoles;
47: protected $table = 'settings';
48: /**
49: * @var string[]
50: */
51: protected $fillable = [
52: 'key',
53: 'value',
54: ];
55: const LOGO = 'logo';
56: const FAVICON = 'favicon';
57: const IMAGE = 'image';
58: public function country()
59: {
60: return $this->belongsTo(Country::class, 'country_id');
61: }
62: }
[app > Models > Slider.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: use Illuminate\Support\Carbon;
6: use Spatie\MediaLibrary\HasMedia;
7: use Spatie\MediaLibrary\InteractsWithMedia;
8: use Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection;
9: use Spatie\MediaLibrary\MediaCollections\Models\Media;
10: /**
11: * App\Models\Slider
12: *
13: * @property int $id
14: * @property string $title
15: * @property string $short_description
16: * @property int $is_default
17: * @property-read string $slider_image
18: * @property Carbon|null $created_at
19: * @property Carbon|null $updated_at
20: * @property-read MediaCollection|Media[] $media
21: * @property-read int|null $media_count
22: *
23: * @method static \Illuminate\Database\Eloquent\Builder|Slider newModelQuery()
24: * @method static \Illuminate\Database\Eloquent\Builder|Slider newQuery()
25: * @method static \Illuminate\Database\Eloquent\Builder|Slider query()
26: * @method static \Illuminate\Database\Eloquent\Builder|Slider whereCreatedAt($value)
27: * @method static \Illuminate\Database\Eloquent\Builder|Slider whereId($value)
28: * @method static \Illuminate\Database\Eloquent\Builder|Slider
29: whereShortDescription($value)
30: * @method static \Illuminate\Database\Eloquent\Builder|Slider whereTitle($value)
31: * @method static \Illuminate\Database\Eloquent\Builder|Slider whereUpdatedAt($value)
32: *
33: * @mixin \Eloquent
34: *
35: * @method static \Illuminate\Database\Eloquent\Builder|Slider whereIsDefault($value)
36: */
37: class Slider extends Model implements HasMedia
38: {
39: use HasFactory, InteractsWithMedia;
40: const SLIDER_IMAGE = 'image';
41: /**
42: * @var string[]
43: */
44: public static $rules = [
45: 'title' => 'required',
46: 'image' => 'required|mimes:jpeg,png,jpg',
47: 'short_description' => 'required',
48: ];
49: /**
50: * @var string[]
51: */
52: public static $editRules = [
53: 'title' => 'required',
54: 'image' => 'nullable|mimes:jpeg,png,jpg',
55: 'short_description' => 'required|max:55',
56: ];
57: /**
58: * @var string
59: */
60: protected $table = 'sliders';
61: /**
62: * @var string[]
63: */
64: protected $fillable = [
65: 'title',
66: 'short_description',
67: 'is_default',
68: ];
69: protected $casts = [
70: 'title' => 'string',
71: 'short_description' => 'string',
72: 'is_default' => 'boolean',
73: ];
74: protected $appends = ['slider_image'];
75: public function getSliderImageAttribute(): string
76: {
77: /** @var Media $media */
78: $media = $this->getMedia(self::SLIDER_IMAGE)->first();
79: if (! empty($media)) {
80: return $media->getFullUrl();
81: }
82: return asset('assets/front/images/home/home-page-image.png');
83: }
84: }
[app > Models > SmartPatientCards.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: use Spatie\MediaLibrary\HasMedia;
6: use Spatie\MediaLibrary\InteractsWithMedia;
7: use Spatie\Permission\Traits\HasRoles;
8: use Illuminate\Database\Eloquent\Relations\HasMany;
9: use App\Models\Patient;
10: use Illuminate\Database\Eloquent\Relations\HasOne;
11: class SmartPatientCards extends Model implements HasMedia
12: {
13: use HasFactory, InteractsWithMedia, HasRoles;
14: protected $table = 'smart_patient_cards';
15: const PROFILE = 'profile';
16: /**
17: * @var string[]
18: */
19: protected $fillable = [
20: 'template_name',
21: 'address',
22: 'header_color',
23: 'show_email',
24: 'show_phone',
25: 'show_dob',
26: 'show_blood_group',
27: 'show_address',
28: 'show_patient_unique_id',
29: ];
30: public static $rules = [
31: 'template_name' => 'required',
32: ];
33: protected $appends = ['profile_image',];
34: public function getProfileImageAttribute(): string
35: {
36: /** @var Media $media */
37: $media = $this->getMedia(self::PROFILE)->first();
38: if (! empty($media)) {
39: return $media->getFullUrl();
40: }
41: return asset('web/media/avatars/male.png');
42: }
43: public function patient():HasOne
44: {
45: return $this->hasOne(Patient::class,'template_id');
46: }
47: }
[app > Models > Specialization.php]
1: <?php
2: namespace App\Models;
3: use Eloquent as Model;
4: use Illuminate\Database\Eloquent\Factories\HasFactory;
5: use Illuminate\Database\Eloquent\Relations\BelongsToMany;
6: use Illuminate\Support\Carbon;
7: /**
8: * Class Specialization
9: *
10: * @version August 2, 2021, 10:19 am UTC
11: *
12: * @property string $name
13: * @property int $id
14: * @property Carbon|null $created_at
15: * @property Carbon|null $updated_at
16: *
17: * @method static \Database\Factories\SpecializationFactory factory(...$parameters)
18: * @method static \Illuminate\Database\Eloquent\Builder|Specialization newModelQuery()
19: * @method static \Illuminate\Database\Eloquent\Builder|Specialization newQuery()
20: * @method static \Illuminate\Database\Eloquent\Builder|Specialization query()
21: * @method static \Illuminate\Database\Eloquent\Builder|Specialization
22: whereCreatedAt($value)
23: * @method static \Illuminate\Database\Eloquent\Builder|Specialization whereId($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|Specialization
whereName($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|Specialization
26: whereUpdatedAt($value)
27: *
28: * @mixin Model
29: *
30: * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Doctor[]
$doctors
31: * @property-read int|null $doctors_count
32: */
33: class Specialization extends Model
34: {
35: use HasFactory;
36: protected $table = 'specializations';
37: public $fillable = [
38: 'name',
39: ];
40: /**
41: * The attributes that should be casted to native types.
42: *
43: * @var array
44: */
45: protected $casts = [
46: 'name' => 'string',
47: ];
48: /**
49: * Validation rules
50: *
51: * @var array
52: */
53: public static $rules = [
54: 'name' => 'required|unique:specializations,name',
55: ];
56: public function doctors(): BelongsToMany
57: {
58: return $this->belongsToMany(Doctor::class);
59: }
60: }
[app > Models > Staff.php]
1: <?php
2: namespace App\Models;
3: use Database\Factories\StaffFactory;
4: use Eloquent as Model;
5: use Illuminate\Database\Eloquent\Builder;
6: use Illuminate\Database\Eloquent\Factories\HasFactory;
7: use Illuminate\Support\Carbon;
8: use Spatie\MediaLibrary\HasMedia;
9: use Spatie\MediaLibrary\InteractsWithMedia;
10: use Spatie\Permission\Traits\HasRoles;
11: /**
12: * Class Staff
13: *
14: * @version August 6, 2021, 10:17 am UTC
15: *
16: * @property string $first_name
17: * @property string $last_name
18: * @property string $email
19: * @property string $phone_number
20: * @property string $password
21: * @property string $gender
22: * @property string $role
23: * @property int $id
24: * @property Carbon|null $created_at
25: * @property Carbon|null $updated_at
26: *
27: * @method static StaffFactory factory(...$parameters)
28: * @method static Builder|Staff newModelQuery()
29: * @method static Builder|Staff newQuery()
30: * @method static Builder|Staff query()
31: * @method static Builder|Staff whereCreatedAt($value)
32: * @method static Builder|Staff whereEmail($value)
33: * @method static Builder|Staff whereFirstName($value)
34: * @method static Builder|Staff whereGender($value)
35: * @method static Builder|Staff whereId($value)
36: * @method static Builder|Staff whereLastName($value)
37: * @method static Builder|Staff wherePassword($value)
38: * @method static Builder|Staff wherePhoneNumber($value)
39: * @method static Builder|Staff whereUpdatedAt($value)
40: *
41: * @mixin Model
42: *
43: * @property-read
44: \Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection|\Spatie\Medi
aLibrary\MediaCollections\Models\Media[]
45: * $media
46: * @property-read int|null $media_count
47: * @property-read
48: \Illuminate\Database\Eloquent\Collection|\Spatie\Permission\Models\Permission[]
49: $permissions
50: * @property-read int|null $permissions_count
51: * @property-read
\Illuminate\Database\Eloquent\Collection|\Spatie\Permission\Models\Role[]
52: $roles
53: * @property-read int|null $roles_count
54: *
55: * @method static Builder|Staff permission($permissions)
56: * @method static Builder|Staff role($roles, $guard = null)
57: */
58: class Staff extends Model implements HasMedia
59: {
60: use HasFactory, InteractsWithMedia, HasRoles;
61: protected $table = 'staff';
62: const PROFILE = 'profile';
63: public $fillable = [
64: 'first_name',
65: 'last_name',
66: 'email',
67: 'phone_number',
68: 'password',
69: 'gender',
70: 'role',
71: ];
72: /**
73: * The attributes that should be casted to native types.
74: *
75: * @var array
76: */
77: protected $casts = [
78: 'first_name' => 'string',
79: 'last_name' => 'string',
80: 'email' => 'string',
81: 'phone_number' => 'string',
82: 'password' => 'string',
83: 'gender' => 'string',
84: 'role' => 'string',
85: ];
86: /**
87: * Validation rules
88: *
89: * @var array
90: */
91: public static $rules = [
92: 'first_name' => 'required',
93: 'last_name' => 'required',
94: 'email' => 'required|email|unique:users,email',
95: 'password' => 'required|same:password_confirmation|min:6',
96: 'contact' => 'nullable|unique:users,contact',
97: 'gender' => 'required',
98: 'role' => 'required',
99: ];
100: }
[app > Models > State.php]
1: <?php
2: namespace App\Models;
3: use Eloquent as Model;
4: use Illuminate\Database\Eloquent\Factories\HasFactory;
5: use Illuminate\Database\Eloquent\Relations\BelongsTo;
6: use Illuminate\Support\Carbon;
7: /**
8: * Class State
9: *
10: * @version July 29, 2021, 11:48 am UTC
11: *
12: * @property string $name
13: * @property int $country_id
14: * @property int $id
15: * @property Carbon|null $created_at
16: * @property Carbon|null $updated_at
17: * @property-read \App\Models\Country $country
18: *
19: * @method static \Illuminate\Database\Eloquent\Builder|State newModelQuery()
20: * @method static \Illuminate\Database\Eloquent\Builder|State newQuery()
21: * @method static \Illuminate\Database\Eloquent\Builder|State query()
22: * @method static \Illuminate\Database\Eloquent\Builder|State whereCountryId($value)
23: * @method static \Illuminate\Database\Eloquent\Builder|State whereCreatedAt($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|State whereId($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|State whereName($value)
26: * @method static \Illuminate\Database\Eloquent\Builder|State whereUpdatedAt($value)
27: *
28: * @mixin Model
29: */
30: class State extends Model
31: {
32: use HasFactory;
33: protected $table = 'states';
34: public $fillable = [
35: 'name',
36: 'country_id',
37: ];
38: /**
39: * The attributes that should be casted to native types.
40: *
41: * @var array
42: */
43: protected $casts = [
44: 'name' => 'string',
45: 'country_id' => 'integer',
46: ];
47: /**
48: * Validation rules
49: *
50: * @var array
51: */
52: public static $rules = [
53: 'name' => 'required|unique:states,name',
54: ];
55: public function country(): BelongsTo
56: {
57: return $this->belongsTo(Country::class, 'country_id');
58: }
59: }
[app > Models > Subscribe.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: use Illuminate\Support\Carbon;
6: /**
7: * App\Models\Subscribe
8: *
9: * @mixin \Eloquent
10: *
11: * @property int $id
12: * @property string $email
13: * @property int $subscribe
14: * @property Carbon|null $created_at
15: * @property Carbon|null $updated_at
16: *
17: * @method static \Illuminate\Database\Eloquent\Builder|Subscribe
whereCreatedAt($value)
18: * @method static \Illuminate\Database\Eloquent\Builder|Subscribe whereEmail($value)
19: * @method static \Illuminate\Database\Eloquent\Builder|Subscribe whereId($value)
20: * @method static \Illuminate\Database\Eloquent\Builder|Subscribe
whereSubscribe($value)
21: * @method static \Illuminate\Database\Eloquent\Builder|Subscribe
whereUpdatedAt($value)
22: * @method static \Illuminate\Database\Eloquent\Builder|Subscribe newModelQuery()
23: * @method static \Illuminate\Database\Eloquent\Builder|Subscribe newQuery()
24: * @method static \Illuminate\Database\Eloquent\Builder|Subscribe query()
25: */
26: class Subscribe extends Model
27: {
28: use HasFactory;
29: protected $table = 'subscribes';
30: const SUBSCRIBE = 1;
31: const SUBSCRIBER = [
32: self::SUBSCRIBE => 'Subscribe',
33: ];
34: public $fillable = [
35: 'email',
36: 'subscribe',
37: ];
38: protected $casts = [
39: 'email' => 'string',
40: 'subscribe' => 'boolean',
41: ];
42: public static $rules = [
43: 'email' =>
44: 'required|email|max:255|regex:/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[
a-z]{2,6}$/ix|unique:subscribes,email',
45: ];
46: }
[app > Models > Transaction.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Builder;
4: use Illuminate\Database\Eloquent\Factories\HasFactory;
5: use Illuminate\Database\Eloquent\Model;
6: use Illuminate\Database\Eloquent\Relations\BelongsTo;
7: use Illuminate\Support\Carbon;
8: /**
9: * App\Models\Transaction
10: *
11: * @property int $id
12: * @property int $user_id
13: * @property string $transaction_id
14: * @property string $appointment_id
15: * @property float $amount
16: * @property int $type
17: * @property string $meta
18: * @property Carbon|null $created_at
19: * @property Carbon|null $updated_at
20: * @property-read User $user
21: *
22: * @method static Builder|Transaction newModelQuery()
23: * @method static Builder|Transaction newQuery()
24: * @method static Builder|Transaction query()
25: * @method static Builder|Transaction whereAmount($value)
26: * @method static Builder|Transaction whereAppointmentId($value)
27: * @method static Builder|Transaction whereCreatedAt($value)
28: * @method static Builder|Transaction whereId($value)
29: * @method static Builder|Transaction whereMeta($value)
30: * @method static Builder|Transaction whereTransactionId($value)
31: * @method static Builder|Transaction whereType($value)
32: * @method static Builder|Transaction whereUpdatedAt($value)
33: * @method static Builder|Transaction whereUserId($value)
34: *
35: * @mixin \Eloquent
36: */
37: class Transaction extends Model
38: {
39: use HasFactory;
40: protected $fillable = [
41: 'user_id',
42: 'transaction_id',
43: 'appointment_id',
44: 'amount',
45: 'meta',
46: 'type',
47: 'status',
48: 'accepted_by',
49: ];
50: protected $table = 'transactions';
51: const SUCCESS = 1;
52: const PENDING = 0;
53: const PAYMENT_STATUS = [
54: self::SUCCESS => 'Success',
55: self::PENDING => 'Pending',
56: ];
57: protected $casts = [
58: 'meta' => 'json',
59: 'transaction_id' => 'string',
60: 'appointment_id' => 'string',
61: 'type' => 'integer',
62: 'accepted_by' => 'integer',
63: 'user_id' => 'integer',
64: 'amount' => 'float',
65: 'status' => 'boolean',
66: ];
67: public function user(): BelongsTo
68: {
69: return $this->belongsTo(User::class, 'user_id');
70: }
71: public function appointment()
72: {
73: return $this->hasOne(Appointment::class, 'appointment_unique_id', 'appointment_id');
74: }
75: public function doctorappointment()
76: {
77: $doctors = Doctor::whereUserId(getLogInUserId())->first();
78: return $this->hasOne(Appointment::class, 'appointment_unique_id',
79: 'appointment_id')->where('doctor_id',
80: $doctors->id);
81: }
82: public function acceptedPaymentUser()
83: {
84: return $this->belongsTo(User::class, 'accepted_by', 'id');
85: }
86: }
[app > Models > UsedMedicine.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Model;
4: /**
5: * App\Models\UsedMedicine
6: *
7: * @property int $id
8: * @property int $stock_used
9: * @property int|null $medicine_id
10: * @property int $model_id
11: * @property string $model_type
12: * @property \Illuminate\Support\Carbon|null $created_at
13: * @property \Illuminate\Support\Carbon|null $updated_at
14: *
15: * @method static \Illuminate\Database\Eloquent\Builder|UsedMedicine newModelQuery()
16: * @method static \Illuminate\Database\Eloquent\Builder|UsedMedicine newQuery()
17: * @method static \Illuminate\Database\Eloquent\Builder|UsedMedicine query()
18: * @method static \Illuminate\Database\Eloquent\Builder|UsedMedicine
whereCreatedAt($value)
19: * @method static \Illuminate\Database\Eloquent\Builder|UsedMedicine whereId($value)
20: * @method static \Illuminate\Database\Eloquent\Builder|UsedMedicine
21: whereMedicineId($value)
22: * @method static \Illuminate\Database\Eloquent\Builder|UsedMedicine
whereModelId($value)
23: * @method static \Illuminate\Database\Eloquent\Builder|UsedMedicine
whereModelType($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|UsedMedicine
whereStockUsed($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|UsedMedicine
whereUpdatedAt($value)
26: *
27: * @mixin \Eloquent
28: */
29: class UsedMedicine extends Model
30: {
31: protected $fillable =
32: [
33: 'medicine_id',
34: 'stock_used',
35: 'model_id',
36: 'model_type',
37: ];
38: protected $table = 'used_medicines';
39: public function medicine()
40: {
41: return $this->belongsTo(Medicine::class, 'medicine_id');
42: }
43: }
[app > Models > User.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Builder;
4: use Illuminate\Database\Eloquent\Collection;
5: use Illuminate\Database\Eloquent\Factories\HasFactory;
6: use Illuminate\Database\Eloquent\Relations\HasMany;
7: use Illuminate\Database\Eloquent\Relations\HasOne;
8: use Illuminate\Database\Eloquent\Relations\MorphOne;
9: use Illuminate\Foundation\Auth\User as Authenticatable;
10: use Illuminate\Notifications\DatabaseNotification;
11: use Illuminate\Notifications\DatabaseNotificationCollection;
12: use Illuminate\Notifications\Notifiable;
13: use Illuminate\Support\Carbon;
14: use Lab404\Impersonate\Models\Impersonate;
15: use Spatie\MediaLibrary\HasMedia;
16: use Spatie\MediaLibrary\InteractsWithMedia;
17: use Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection;
18: use Spatie\MediaLibrary\MediaCollections\Models\Media;
19: use Spatie\Permission\Traits\HasRoles;
20: /**
21: * App\Models\User
22: *
23: * @property int $id
24: * @property string $first_name
25: * @property string $last_name
26: * @property string $email
27: * @property string $contact
28: * @property string|null $dob
29: * @property int $gender
30: * @property int $status
31: * @property string|null $language
32: * @property Carbon|null $email_verified_at
33: * @property string $password
34: * @property string|null $remember_token
35: * @property Carbon|null $created_at
36: * @property Carbon|null $updated_at
37: * @property-read Address|null $address
38: * @property-read Doctor|null $doctor
39: * @property-read string $full_name
40: * @property-read string $profile_image
41: * @property-read MediaCollection|Media[] $media
42: * @property-read int|null $media_count
43: * @property-read DatabaseNotificationCollection|DatabaseNotification[]
44: * $notifications
45: * @property-read int|null $notifications_count
46: * @property-read Patient|null $patient
47: *
48: * @method static \Database\Factories\UserFactory factory(...$parameters)
49: * @method static Builder|User newModelQuery()
50: * @method static Builder|User newQuery()
51: * @method static Builder|User query()
52: * @method static Builder|User whereContact($value)
53: * @method static Builder|User whereCreatedAt($value)
54: * @method static Builder|User whereDob($value)
55: * @method static Builder|User whereEmail($value)
56: * @method static Builder|User whereEmailVerifiedAt($value)
57: * @method static Builder|User whereFirstName($value)
58: * @method static Builder|User whereGender($value)
59: * @method static Builder|User whereId($value)
60: * @method static Builder|User whereLanguage($value)
61: * @method static Builder|User whereLastName($value)
62: * @method static Builder|User wherePassword($value)
63: * @method static Builder|User whereRememberToken($value)
64: * @method static Builder|User whereStatus($value)
65: * @method static Builder|User whereUpdatedAt($value)
66: *
67: * @property int|null $type
68: * @property string|null $blood_group
69: * @property-read mixed $role_name
70: * @property-read Collection|\Spatie\Permission\Models\Permission[] $permissions
71: * @property-read int|null $permissions_count
72: * @property-read Collection|Qualification[] $qualifications
73: * @property-read int|null $qualifications_count
74: * @property-read Collection|\Spatie\Permission\Models\Role[] $roles
75: * @property-read int|null $roles_count
76: *
77: * @method static Builder|User permission($permissions)
78: * @method static Builder|User role($roles, $guard = null)
79: * @method static Builder|User whereBloodGroup($value)
80: * @method static Builder|User whereType($value)
81: *
82: * @property-read \App\Models\Staff|null $staff
83: * @property string|null $region_code
84: *
85: * @method static Builder|User whereRegionCode($value)
86: */
87: class User extends Authenticatable implements HasMedia
88: {
89: use HasFactory, Notifiable, InteractsWithMedia, HasRoles, Impersonate;
90: protected $table = 'users';
91: /**
92: * The attributes that are mass assignable.
93: *
94: * @var array
95: */
96: protected $fillable = [
97: 'first_name',
98: 'last_name',
99: 'email',
100: 'contact',
101: 'dob',
102: 'gender',
103: 'status',
104: 'password',
105: 'language',
106: 'blood_group',
107: 'type',
108: 'region_code',
109: 'email_verified_at',
110: 'email_notification',
111: 'time_zone',
112: 'dark_mode',
113: ];
114: const LANGUAGES = [
115: 'en' => 'English',
116: 'es' => 'Spanish',
117: 'fr' => 'French',
118: 'de' => 'German',
119: 'ru' => 'Russian',
120: 'pt' => 'Portuguese',
121: 'ar' => 'Arabic',
122: 'zh' => 'Chinese',
123: 'tr' => 'Turkish',
124: 'it' => 'Italian',
125: ];
126: const LANGUAGES_IMAGE = [
127: 'en' => 'web/media/flags/united-states.svg',
128: 'es' => 'web/media/flags/spain.svg',
129: 'fr' => 'web/media/flags/france.svg',
130: 'de' => 'web/media/flags/germany.svg',
131: 'ru' => 'web/media/flags/russia.svg',
132: 'pt' => 'web/media/flags/portugal.svg',
133: 'ar' => 'web/media/flags/iraq.svg',
134: 'zh' => 'web/media/flags/china.svg',
135: 'tr' => 'web/media/flags/turkey.svg',
136: 'it' => 'web/media/flags/italy.svg',
137: ];
138: const PROFILE = 'profile';
139: const ADMIN = 1;
140: const DOCTOR = 2;
141: const PATIENT = 3;
142: const STAFF = 4;
143: const TYPE = [
144: self::ADMIN => 'Admin',
145: self::DOCTOR => 'Doctor',
146: self::PATIENT => 'Patient',
147: self::STAFF => 'Staff',
148: ];
149: const ALL = 2;
150: const ACTIVE = 1;
151: const DEACTIVE = 0;
152: const STATUS = [
153: self::ALL => 'All',
154: self::ACTIVE => 'Active',
155: self::DEACTIVE => 'Deactive',
156: ];
157: const TIME_ZONE_ARRAY = [
158: 'Africa/Abidjan',
159: 'Africa/Accra',
160: 'Africa/Algiers',
161: 'Africa/Bissau',
162: 'Africa/Cairo',
163: 'Africa/Casablanca',
164: 'Africa/Ceuta',
165: 'Africa/El_Aaiun',
166: 'Africa/Johannesburg',
167: 'Africa/Juba',
168: 'Africa/Khartoum',
169: 'Africa/Lagos',
170: 'Africa/Maputo',
171: 'Africa/Monrovia',
172: 'Africa/Nairobi',
173: 'Africa/Ndjamena',
174: 'Africa/Sao_Tome',
175: 'Africa/Tripoli',
176: 'Africa/Tunis',
177: 'Africa/Windhoek',
178: 'America/Adak',
179: 'America/Anchorage',
180: 'America/Araguaina',
181: 'America/Argentina/Buenos_Aires',
182: 'America/Argentina/Catamarca',
183: 'America/Argentina/Cordoba',
184: 'America/Argentina/Jujuy',
185: 'America/Argentina/La_Rioja',
186: 'America/Argentina/Mendoza',
187: 'America/Argentina/Rio_Gallegos',
188: 'America/Argentina/Salta',
189: 'America/Argentina/San_Juan',
190: 'America/Argentina/San_Luis',
191: 'America/Argentina/Tucuman',
192: 'America/Argentina/Ushuaia',
193: 'America/Asuncion',
194: 'America/Atikokan',
195: 'America/Bahia',
196: 'America/Bahia_Banderas',
197: 'America/Barbados',
198: 'America/Belem',
199: 'America/Belize',
200: 'America/Blanc-Sablon',
201: 'America/Boa_Vista',
202: 'America/Bogota',
203: 'America/Boise',
204: 'America/Cambridge_Bay',
205: 'America/Campo_Grande',
206: 'America/Cancun',
207: 'America/Caracas',
208: 'America/Cayenne',
209: 'America/Chicago',
210: 'America/Chihuahua',
211: 'America/Costa_Rica',
212: 'America/Creston',
213: 'America/Cuiaba',
214: 'America/Curacao',
215: 'America/Danmarkshavn',
216: 'America/Dawson',
217: 'America/Dawson_Creek',
218: 'America/Denver',
219: 'America/Detroit',
220: 'America/Edmonton',
221: 'America/Eirunepe',
222: 'America/El_Salvador',
223: 'America/Fort_Nelson',
224: 'America/Fortaleza',
225: 'America/Glace_Bay',
226: 'America/Godthab',
227: 'America/Goose_Bay',
228: 'America/Grand_Turk',
229: 'America/Guatemala',
230: 'America/Guayaquil',
231: 'America/Guyana',
232: 'America/Halifax',
233: 'America/Havana',
234: 'America/Hermosillo',
235: 'America/Indiana/Indianapolis',
236: 'America/Indiana/Knox',
237: 'America/Indiana/Marengo',
238: 'America/Indiana/Petersburg',
239: 'America/Indiana/Tell_City',
240: 'America/Indiana/Vevay',
241: 'America/Indiana/Vincennes',
242: 'America/Indiana/Winamac',
243: 'America/Inuvik',
244: 'America/Iqaluit',
245: 'America/Jamaica',
246: 'America/Juneau',
247: 'America/Kentucky/Louisville',
248: 'America/Kentucky/Monticello',
249: 'America/La_Paz',
250: 'America/Lima',
251: 'America/Los_Angeles',
252: 'America/Maceio',
253: 'America/Managua',
254: 'America/Manaus',
255: 'America/Martinique',
256: 'America/Matamoros',
257: 'America/Mazatlan',
258: 'America/Menominee',
259: 'America/Merida',
260: 'America/Metlakatla',
261: 'America/Mexico_City',
262: 'America/Miquelon',
263: 'America/Moncton',
264: 'America/Monterrey',
265: 'America/Montevideo',
266: 'America/Nassau',
267: 'America/New_York',
268: 'America/Nipigon',
269: 'America/Nome',
270: 'America/Noronha',
271: 'America/North_Dakota/Beulah',
272: 'America/North_Dakota/Center',
273: 'America/North_Dakota/New_Salem',
274: 'America/Ojinaga',
275: 'America/Panama',
276: 'America/Pangnirtung',
277: 'America/Paramaribo',
278: 'America/Phoenix',
279: 'America/Port_of_Spain',
280: 'America/Port-au-Prince',
281: 'America/Porto_Velho',
282: 'America/Puerto_Rico',
283: 'America/Punta_Arenas',
284: 'America/Rainy_River',
285: 'America/Rankin_Inlet',
286: 'America/Recife',
287: 'America/Regina',
288: 'America/Resolute',
289: 'America/Rio_Branco',
290: 'America/Santarem',
291: 'America/Santiago',
292: 'America/Santo_Domingo',
293: 'America/Sao_Paulo',
294: 'America/Scoresbysund',
295: 'America/Sitka',
296: 'America/St_Johns',
297: 'America/Swift_Current',
298: 'America/Tegucigalpa',
299: 'America/Thule',
300: 'America/Thunder_Bay',
301: 'America/Tijuana',
302: 'America/Toronto',
303: 'America/Vancouver',
304: 'America/Whitehorse',
305: 'America/Winnipeg',
306: 'America/Yakutat',
307: 'America/Yellowknife',
308: 'Antarctica/Casey',
309: 'Antarctica/Davis',
310: 'Antarctica/DumontDUrville', //
311: https://bugs.chromium.org/p/chromium/issues/detail?id=928068
312: 'Antarctica/Macquarie',
313: 'Antarctica/Mawson',
314: 'Antarctica/Palmer',
315: 'Antarctica/Rothera',
316: 'Antarctica/Syowa',
317: 'Antarctica/Troll',
318: 'Antarctica/Vostok',
319: 'Asia/Almaty',
320: 'Asia/Amman',
321: 'Asia/Anadyr',
322: 'Asia/Aqtau',
323: 'Asia/Aqtobe',
324: 'Asia/Ashgabat',
325: 'Asia/Atyrau',
326: 'Asia/Baghdad',
327: 'Asia/Baku',
328: 'Asia/Bangkok',
329: 'Asia/Barnaul',
330: 'Asia/Beirut',
331: 'Asia/Bishkek',
332: 'Asia/Brunei',
333: 'Asia/Chita',
334: 'Asia/Choibalsan',
335: 'Asia/Colombo',
336: 'Asia/Damascus',
337: 'Asia/Dhaka',
338: 'Asia/Dili',
339: 'Asia/Dubai',
340: 'Asia/Dushanbe',
341: 'Asia/Famagusta',
342: 'Asia/Gaza',
343: 'Asia/Hebron',
344: 'Asia/Ho_Chi_Minh',
345: 'Asia/Hong_Kong',
346: 'Asia/Hovd',
347: 'Asia/Irkutsk',
348: 'Asia/Jakarta',
349: 'Asia/Jayapura',
350: 'Asia/Jerusalem',
351: 'Asia/Kabul',
352: 'Asia/Kamchatka',
353: 'Asia/Karachi',
354: 'Asia/Kathmandu',
355: 'Asia/Khandyga',
356: 'Asia/Kolkata',
357: 'Asia/Krasnoyarsk',
358: 'Asia/Kuala_Lumpur',
359: 'Asia/Kuching',
360: 'Asia/Macau',
361: 'Asia/Magadan',
362: 'Asia/Makassar',
363: 'Asia/Manila',
364: 'Asia/Nicosia',
365: 'Asia/Novokuznetsk',
366: 'Asia/Novosibirsk',
367: 'Asia/Omsk',
368: 'Asia/Oral',
369: 'Asia/Pontianak',
370: 'Asia/Pyongyang',
371: 'Asia/Qatar',
372: 'Asia/Qostanay', // https://bugs.chromium.org/p/chromium/issues/detail?id=928068
373: 'Asia/Qyzylorda',
374: 'Asia/Riyadh',
375: 'Asia/Sakhalin',
376: 'Asia/Samarkand',
377: 'Asia/Seoul',
378: 'Asia/Shanghai',
379: 'Asia/Singapore',
380: 'Asia/Srednekolymsk',
381: 'Asia/Taipei',
382: 'Asia/Tashkent',
383: 'Asia/Tbilisi',
384: 'Asia/Tehran',
385: 'Asia/Thimphu',
386: 'Asia/Tokyo',
387: 'Asia/Tomsk',
388: 'Asia/Ulaanbaatar',
389: 'Asia/Urumqi',
390: 'Asia/Ust-Nera',
391: 'Asia/Vladivostok',
392: 'Asia/Yakutsk',
393: 'Asia/Yangon',
394: 'Asia/Yekaterinburg',
395: 'Asia/Yerevan',
396: 'Atlantic/Azores',
397: 'Atlantic/Bermuda',
398: 'Atlantic/Canary',
399: 'Atlantic/Cape_Verde',
400: 'Atlantic/Faroe',
401: 'Atlantic/Madeira',
402: 'Atlantic/Reykjavik',
403: 'Atlantic/South_Georgia',
404: 'Atlantic/Stanley',
405: 'Australia/Adelaide',
406: 'Australia/Brisbane',
407: 'Australia/Broken_Hill',
408: 'Australia/Currie',
409: 'Australia/Darwin',
410: 'Australia/Eucla',
411: 'Australia/Hobart',
412: 'Australia/Lindeman',
413: 'Australia/Lord_Howe',
414: 'Australia/Melbourne',
415: 'Australia/Perth',
416: 'Australia/Sydney',
417: 'Europe/Amsterdam',
418: 'Europe/Andorra',
419: 'Europe/Astrakhan',
420: 'Europe/Athens',
421: 'Europe/Belgrade',
422: 'Europe/Berlin',
423: 'Europe/Brussels',
424: 'Europe/Bucharest',
425: 'Europe/Budapest',
426: 'Europe/Chisinau',
427: 'Europe/Copenhagen',
428: 'Europe/Dublin',
429: 'Europe/Gibraltar',
430: 'Europe/Helsinki',
431: 'Europe/Istanbul',
432: 'Europe/Kaliningrad',
433: 'Europe/Kiev',
434: 'Europe/Kirov',
435: 'Europe/Lisbon',
436: 'Europe/London',
437: 'Europe/Luxembourg',
438: 'Europe/Madrid',
439: 'Europe/Malta',
440: 'Europe/Minsk',
441: 'Europe/Monaco',
442: 'Europe/Moscow',
443: 'Europe/Oslo',
444: 'Europe/Paris',
445: 'Europe/Prague',
446: 'Europe/Riga',
447: 'Europe/Rome',
448: 'Europe/Samara',
449: 'Europe/Saratov',
450: 'Europe/Simferopol',
451: 'Europe/Sofia',
452: 'Europe/Stockholm',
453: 'Europe/Tallinn',
454: 'Europe/Tirane',
455: 'Europe/Ulyanovsk',
456: 'Europe/Uzhgorod',
457: 'Europe/Vienna',
458: 'Europe/Vilnius',
459: 'Europe/Volgograd',
460: 'Europe/Warsaw',
461: 'Europe/Zaporozhye',
462: 'Europe/Zurich',
463: 'Indian/Chagos',
464: 'Indian/Christmas',
465: 'Indian/Cocos',
466: 'Indian/Kerguelen',
467: 'Indian/Mahe',
468: 'Indian/Maldives',
469: 'Indian/Mauritius',
470: 'Indian/Reunion',
471: 'Pacific/Apia',
472: 'Pacific/Auckland',
473: 'Pacific/Bougainville',
474: 'Pacific/Chatham',
475: 'Pacific/Chuuk',
476: 'Pacific/Easter',
477: 'Pacific/Efate',
478: 'Pacific/Enderbury',
479: 'Pacific/Fakaofo',
480: 'Pacific/Fiji',
481: 'Pacific/Funafuti',
482: 'Pacific/Galapagos',
483: 'Pacific/Gambier',
484: 'Pacific/Guadalcanal',
485: 'Pacific/Guam',
486: 'Pacific/Honolulu',
487: 'Pacific/Kiritimati',
488: 'Pacific/Kosrae',
489: 'Pacific/Kwajalein',
490: 'Pacific/Majuro',
491: 'Pacific/Marquesas',
492: 'Pacific/Nauru',
493: 'Pacific/Niue',
494: 'Pacific/Norfolk',
495: 'Pacific/Noumea',
496: 'Pacific/Pago_Pago',
497: 'Pacific/Palau',
498: 'Pacific/Pitcairn',
499: 'Pacific/Pohnpei',
500: 'Pacific/Port_Moresby',
501: 'Pacific/Rarotonga',
502: 'Pacific/Tahiti',
503: 'Pacific/Tarawa',
504: 'Pacific/Tongatapu',
505: 'Pacific/Wake',
506: 'Pacific/Wallis',
507: ];
508: // protected $with = ['media', 'roles'];
509: protected $appends = ['full_name', 'profile_image', 'role_name',
'role_display_name'];
510: /**
511: * The attributes that should be hidden for arrays.
512: *
513: * @var array
514: */
515: protected $hidden = [
516: 'password',
517: 'remember_token',
518: ];
519: const MALE = 1;
520: const FEMALE = 2;
521: const GENDER = [
522: self::MALE => 'Male',
523: self::FEMALE => 'Female',
524: ];
525: public static $rules = [
526: 'first_name' => 'required',
527: 'last_name' => 'required',
528: 'email' => 'required|email|unique:users,email|regex:/(.*)@(.*)\.(.*)/',
529: 'contact' => 'nullable|unique:users,contact',
530: 'password' => 'required|same:password_confirmation|min:6',
531: 'dob' => 'nullable|date',
532: 'experience' => 'nullable|numeric',
533: 'specializations' => 'required',
534: 'gender' => 'required',
535: 'status' => 'nullable',
536: 'postal_code' => 'nullable',
537: 'profile' => 'nullable|mimes:jpeg,png,jpg|max:2000',
538: ];
539: /**
540: * The attributes that should be cast to native types.
541: *
542: * @var array
543: */
544: protected $casts = [
545: 'email_verified_at' => 'datetime',
546: 'first_name' => 'string',
547: 'last_name' => 'string',
548: 'email' => 'string',
549: 'contact' => 'string',
550: 'dob' => 'string',
551: 'gender' => 'integer',
552: 'status' => 'boolean',
553: 'password' => 'string',
554: 'language' => 'string',
555: 'blood_group' => 'string',
556: 'type' => 'integer',
557: 'region_code' => 'string',
558: 'email_notification' => 'boolean',
559: 'time_zone' => 'string',
560: 'dark_mode' => 'boolean',
561: ];
562: public function getProfileImageAttribute(): string
563: {
564: /** @var Media $media */
565: $media = $this->getMedia(self::PROFILE)->first();
566: if (! empty($media)) {
567: return $media->getFullUrl();
568: }
569: $gender = $this->gender;
570: if ($gender == self::FEMALE) {
571: return asset('web/media/avatars/female.png');
572: }
573: return asset('web/media/avatars/male.png');
574: }
575: public function getRoleNameAttribute()
576: {
577: $role = $this->roles->first();
578: if (! empty($role)) {
579: return $role->display_name;
580: }
581: }
582: public function getRoleDisplayNameAttribute()
583: {
584: $role = $this->roles->first();
585: if (! empty($role)) {
586: return $role->name;
587: }
588: }
589: public function getFullNameAttribute(): string
590: {
591: return $this->first_name.' '.$this->last_name;
592: }
593: public function address(): MorphOne
594: {
595: return $this->morphOne(Address::class, 'owner');
596: }
597: public function doctor(): HasOne
598: {
599: return $this->hasOne(Doctor::class, 'user_id');
600: }
601: public function qualifications(): HasMany
602: {
603: return $this->hasMany(Qualification::class, 'user_id');
604: }
605: public function patient(): HasOne
606: {
607: return $this->hasOne(Patient::class, 'user_id');
608: }
609: public function staff(): HasOne
610: {
611: return $this->hasOne(Staff::class);
612: }
613: public function gCredentials(): HasOne
614: {
615: return $this->hasOne(GoogleCalendarIntegration::class, 'user_id');
616: }
617: }
[app > Models > UserGoogleAppointment.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: use Illuminate\Database\Eloquent\Relations\BelongsTo;
6: class UserGoogleAppointment extends Model
7: {
8: use HasFactory;
9: protected $table = 'user_google_appointments';
10: public $fillable = [
11: 'user_id',
12: 'appointment_id',
13: 'google_calendar_id',
14: 'google_event_id',
15: ];
16: protected $casts = [
17: 'user_id' => 'integer',
18: 'appointment_id' => 'string',
19: 'google_calendar_id' => 'string',
20: 'google_event_id' => 'string',
21: ];
22: public function user(): BelongsTo
23: {
24: return $this->belongsTo(User::class, 'user_id');
25: }
26: }
[app > Models > UserZoomCredential.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Model;
4: use Illuminate\Database\Eloquent\Relations\BelongsTo;
5: /**
6: * App\Models\UserZoomCredential
7: *
8: * @property int $id
9: * @property int $user_id
10: * @property string $zoom_api_key
11: * @property string $zoom_api_secret
12: * @property \Illuminate\Support\Carbon|null $created_at
13: * @property \Illuminate\Support\Carbon|null $updated_at
14: * @property-read \App\Models\User $user
15: *
16: * @method static \Illuminate\Database\Eloquent\Builder|UserZoomCredential
newModelQuery()
17: * @method static \Illuminate\Database\Eloquent\Builder|UserZoomCredential newQuery()
18: * @method static \Illuminate\Database\Eloquent\Builder|UserZoomCredential query()
19: * @method static \Illuminate\Database\Eloquent\Builder|UserZoomCredential
20: whereCreatedAt($value)
21: * @method static \Illuminate\Database\Eloquent\Builder|UserZoomCredential
whereId($value)
22: * @method static \Illuminate\Database\Eloquent\Builder|UserZoomCredential
23: whereUpdatedAt($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|UserZoomCredential
25: whereUserId($value)
26: * @method static \Illuminate\Database\Eloquent\Builder|UserZoomCredential
27: whereZoomApiKey($value)
28: * @method static \Illuminate\Database\Eloquent\Builder|UserZoomCredential
29: whereZoomApiSecret($value)
30: *
31: * @mixin \Eloquent
32: */
33: class UserZoomCredential extends Model
34: {
35: /**
36: * Validation rules
37: *
38: * @var array
39: */
40: public static $rules = [
41: 'zoom_api_key' => 'required',
42: 'zoom_api_secret' => 'required',
43: ];
44: protected $table = 'user_zoom_credential';
45: protected $fillable = [
46: 'user_id',
47: 'zoom_api_key',
48: 'zoom_api_secret',
49: ];
50: protected $casts = [
51: 'user_id' => 'integer',
52: 'zoom_api_key' => 'string',
53: 'zoom_api_secret' => 'string',
54: ];
55: public function user(): BelongsTo
56: {
57: return $this->belongsTo(User::class, 'user_id');
58: }
59: }
[app > Models > Visit.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: use Illuminate\Database\Eloquent\Relations\BelongsTo;
6: use Illuminate\Database\Eloquent\Relations\HasMany;
7: use Illuminate\Support\Carbon;
8: /**
9: * Class Encounter
10: *
11: * @version September 3, 2021, 7:09 am UTC
12: *
13: * @property string $doctor
14: * @property string $patient
15: * @property string $description
16: * @property int $id
17: * @property int $doctor_id
18: * @property int $patient_id
19: * @property Carbon|null $created_at
20: * @property Carbon|null $updated_at
21: *
22: * @method static \Database\Factories\EncounterFactory factory(...$parameters)
23: * @method static \Illuminate\Database\Eloquent\Builder|Visit newModelQuery()
24: * @method static \Illuminate\Database\Eloquent\Builder|Visit newQuery()
25: * @method static \Illuminate\Database\Eloquent\Builder|Visit query()
26: * @method static \Illuminate\Database\Eloquent\Builder|Visit whereCreatedAt($value)
27: * @method static \Illuminate\Database\Eloquent\Builder|Visit whereDescription($value)
28: * @method static \Illuminate\Database\Eloquent\Builder|Visit whereDoctorId($value)
29: * @method static \Illuminate\Database\Eloquent\Builder|Visit
whereEncounterDate($value)
30: * @method static \Illuminate\Database\Eloquent\Builder|Visit whereId($value)
31: * @method static \Illuminate\Database\Eloquent\Builder|Visit wherePatientId($value)
32: * @method static \Illuminate\Database\Eloquent\Builder|Visit whereUpdatedAt($value)
33: *
34: * @mixin Model
35: *
36: * @property string $visit_date
37: * @property-read Doctor $visitDoctor
38: * @property-read \App\Models\Patient $visitPatient
39: *
40: * @method static \Illuminate\Database\Eloquent\Builder|Visit whereVisitDate($value)
41: */
42: class Visit extends Model
43: {
44: use HasFactory;
45: public $table = 'visits';
46: public $fillable = [
47: 'visit_date',
48: 'doctor_id',
49: 'patient_id',
50: 'description',
51: ];
52: /**
53: * The attributes that should be casted to native types.
54: *
55: * @var array
56: */
57: protected $casts = [
58: 'visit_date' => 'string',
59: 'doctor' => 'integer',
60: 'patient' => 'integer',
61: 'description' => 'string',
62: ];
63: /**
64: * Validation rules
65: *
66: * @var array
67: */
68: public static $rules = [
69: 'visit_date' => 'required',
70: 'doctor_id' => 'required',
71: 'patient_id' => 'required',
72: ];
73: public function visitDoctor(): BelongsTo
74: {
75: return $this->belongsTo(Doctor::class, 'doctor_id');
76: }
77: public function doctor(): BelongsTo
78: {
79: return $this->belongsTo(Doctor::class, 'doctor_id');
80: }
81: public function patient(): BelongsTo
82: {
83: return $this->belongsTo(Patient::class, 'patient_id');
84: }
85: public function visitPatient(): BelongsTo
86: {
87: return $this->belongsTo(Patient::class, 'patient_id');
88: }
89: public function problems(): HasMany
90: {
91: return $this->hasMany(VisitProblem::class, 'visit_id');
92: }
93: public function observations(): HasMany
94: {
95: return $this->hasMany(VisitObservation::class, 'visit_id');
96: }
97: public function notes(): HasMany
98: {
99: return $this->hasMany(VisitNote::class, 'visit_id');
100: }
101: public function prescriptions(): HasMany
102: {
103: return $this->hasMany(VisitPrescription::class, 'visit_id');
104: }
105: }
[app > Models > VisitNote.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: use Illuminate\Database\Eloquent\Relations\BelongsTo;
6: use Illuminate\Support\Carbon;
7: /**
8: * App\Models\VisitNote
9: *
10: * @property int $id
11: * @property string $note_name
12: * @property int $visit_id
13: * @property Carbon|null $created_at
14: * @property Carbon|null $updated_at
15: *
16: * @method static \Illuminate\Database\Eloquent\Builder|VisitNote newModelQuery()
17: * @method static \Illuminate\Database\Eloquent\Builder|VisitNote newQuery()
18: * @method static \Illuminate\Database\Eloquent\Builder|VisitNote query()
19: * @method static \Illuminate\Database\Eloquent\Builder|VisitNote
whereCreatedAt($value)
20: * @method static \Illuminate\Database\Eloquent\Builder|VisitNote whereId($value)
21: * @method static \Illuminate\Database\Eloquent\Builder|VisitNote
whereNoteName($value)
22: * @method static \Illuminate\Database\Eloquent\Builder|VisitNote
whereUpdatedAt($value)
23: * @method static \Illuminate\Database\Eloquent\Builder|VisitNote whereVisitId($value)
24: *
25: * @mixin \Eloquent
26: */
27: class VisitNote extends Model
28: {
29: use HasFactory;
30: public $table = 'visit_notes';
31: public $fillable = [
32: 'note_name',
33: 'visit_id',
34: ];
35: /**
36: * The attributes that should be casted to native types.
37: *
38: * @var array
39: */
40: protected $casts = [
41: 'note_name' => 'string',
42: 'visit_id' => 'integer',
43: ];
44: public function visit(): BelongsTo
45: {
46: return $this->belongsTo(Visit::class, 'visit_id');
47: }
48: }
[app > Models > VisitObservation.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: use Illuminate\Database\Eloquent\Relations\BelongsTo;
6: use Illuminate\Support\Carbon;
7: /**
8: * App\Models\VisitObservation
9: *
10: * @property int $id
11: * @property string $observation_name
12: * @property int $visit_id
13: * @property Carbon|null $created_at
14: * @property Carbon|null $updated_at
15: *
16: * @method static \Illuminate\Database\Eloquent\Builder|VisitObservation
newModelQuery()
17: * @method static \Illuminate\Database\Eloquent\Builder|VisitObservation newQuery()
18: * @method static \Illuminate\Database\Eloquent\Builder|VisitObservation query()
19: * @method static \Illuminate\Database\Eloquent\Builder|VisitObservation
20: whereCreatedAt($value)
21: * @method static \Illuminate\Database\Eloquent\Builder|VisitObservation
whereId($value)
22: * @method static \Illuminate\Database\Eloquent\Builder|VisitObservation
23: whereObservationName($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|VisitObservation
25: whereUpdatedAt($value)
26: * @method static \Illuminate\Database\Eloquent\Builder|VisitObservation
27: whereVisitId($value)
28: *
29: * @mixin \Eloquent
30: */
31: class VisitObservation extends Model
32: {
33: use HasFactory;
34: public $table = 'visit_observations';
35: public $fillable = [
36: 'observation_name',
37: 'visit_id',
38: ];
39: /**
40: * The attributes that should be casted to native types.
41: *
42: * @var array
43: */
44: protected $casts = [
45: 'observation_name' => 'string',
46: 'visit_id' => 'integer',
47: ];
48: public function visit(): BelongsTo
49: {
50: return $this->belongsTo(Visit::class, 'visit_id');
51: }
52: }
[app > Models > VisitPrescription.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: use Illuminate\Support\Carbon;
6: /**
7: * App\Models\VisitPrescription
8: *
9: * @property int $id
10: * @property int $visit_id
11: * @property string $prescription_name
12: * @property string $frequency
13: * @property string $duration
14: * @property mixed $description
15: * @property Carbon|null $created_at
16: * @property Carbon|null $updated_at
17: *
18: * @method static \Illuminate\Database\Eloquent\Builder|VisitPrescription
newModelQuery()
19: * @method static \Illuminate\Database\Eloquent\Builder|VisitPrescription newQuery()
20: * @method static \Illuminate\Database\Eloquent\Builder|VisitPrescription query()
21: * @method static \Illuminate\Database\Eloquent\Builder|VisitPrescription
22: whereCreatedAt($value)
23: * @method static \Illuminate\Database\Eloquent\Builder|VisitPrescription
24: whereDescription($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|VisitPrescription
26: whereDuration($value)
27: * @method static \Illuminate\Database\Eloquent\Builder|VisitPrescription
28: whereFrequency($value)
29: * @method static \Illuminate\Database\Eloquent\Builder|VisitPrescription
whereId($value)
30: * @method static \Illuminate\Database\Eloquent\Builder|VisitPrescription
31: wherePrescriptionName($value)
32: * @method static \Illuminate\Database\Eloquent\Builder|VisitPrescription
33: whereUpdatedAt($value)
34: * @method static \Illuminate\Database\Eloquent\Builder|VisitPrescription
35: whereVisitId($value)
36: *
37: * @mixin \Eloquent
38: */
39: class VisitPrescription extends Model
40: {
41: use HasFactory;
42: protected $table = 'visit_prescriptions';
43: public $fillable = [
44: 'visit_id',
45: 'prescription_name',
46: 'frequency',
47: 'duration',
48: 'description',
49: ];
50: protected $casts = [
51: 'visit_id' => 'integer',
52: 'prescription_name' => 'string',
53: 'frequency' => 'string',
54: 'duration' => 'string',
55: 'description' => 'string',
56: ];
57: /**
58: * Validation rules
59: *
60: * @var array
61: */
62: public static $rules = [
63: 'prescription_name' => 'required|max:121',
64: 'frequency' => 'required',
65: 'duration' => 'required',
66: ];
67: }
[app > Models > VisitProblem.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: use Illuminate\Database\Eloquent\Relations\BelongsTo;
6: use Illuminate\Support\Carbon;
7: /**
8: * App\Models\VisitProblem
9: *
10: * @property int $id
11: * @property string $problem_name
12: * @property int $visit_id
13: * @property Carbon|null $created_at
14: * @property Carbon|null $updated_at
15: *
16: * @method static \Illuminate\Database\Eloquent\Builder|VisitProblem newModelQuery()
17: * @method static \Illuminate\Database\Eloquent\Builder|VisitProblem newQuery()
18: * @method static \Illuminate\Database\Eloquent\Builder|VisitProblem query()
19: * @method static \Illuminate\Database\Eloquent\Builder|VisitProblem
whereCreatedAt($value)
20: * @method static \Illuminate\Database\Eloquent\Builder|VisitProblem whereId($value)
21: * @method static \Illuminate\Database\Eloquent\Builder|VisitProblem
22: whereProblemName($value)
23: * @method static \Illuminate\Database\Eloquent\Builder|VisitProblem
whereUpdatedAt($value)
24: * @method static \Illuminate\Database\Eloquent\Builder|VisitProblem
whereVisitId($value)
25: *
26: * @mixin \Eloquent
27: */
28: class VisitProblem extends Model
29: {
30: use HasFactory;
31: public $table = 'visit_problems';
32: public $fillable = [
33: 'problem_name',
34: 'visit_id',
35: ];
36: /**
37: * The attributes that should be casted to native types.
38: *
39: * @var array
40: */
41: protected $casts = [
42: 'problem_name' => 'string',
43: 'visit_id' => 'integer',
44: ];
45: public function visit(): BelongsTo
46: {
47: return $this->belongsTo(Visit::class, 'visit_id');
48: }
49: }
[app > Models > WeekDay.php]
1: <?php
2: namespace App\Models;
3: use Eloquent;
4: use Illuminate\Database\Eloquent\Factories\HasFactory;
5: use Illuminate\Database\Eloquent\Model;
6: use Illuminate\Support\Carbon;
7: /**
8: * App\Models\WeekDay
9: *
10: * @property int $id
11: * @property int $doctor_id
12: * @property int $doctor_session_id
13: * @property string $day_of_week
14: * @property string $start_time
15: * @property string $end_time
16: * @property string $start_time_type
17: * @property string $end_time_type
18: * @property Carbon|null $created_at
19: * @property Carbon|null $updated_at
20: *
21: * @method static \Illuminate\Database\Eloquent\Builder|WeekDay newModelQuery()
22: * @method static \Illuminate\Database\Eloquent\Builder|WeekDay newQuery()
23: * @method static \Illuminate\Database\Eloquent\Builder|WeekDay query()
24: * @method static \Illuminate\Database\Eloquent\Builder|WeekDay whereCreatedAt($value)
25: * @method static \Illuminate\Database\Eloquent\Builder|WeekDay whereDayOfWeek($value)
26: * @method static \Illuminate\Database\Eloquent\Builder|WeekDay whereDoctorId($value)
27: * @method static \Illuminate\Database\Eloquent\Builder|WeekDay
28: whereDoctorSessionId($value)
29: * @method static \Illuminate\Database\Eloquent\Builder|WeekDay whereEndTime($value)
30: * @method static \Illuminate\Database\Eloquent\Builder|WeekDay
whereEndTimeType($value)
31: * @method static \Illuminate\Database\Eloquent\Builder|WeekDay whereId($value)
32: * @method static \Illuminate\Database\Eloquent\Builder|WeekDay whereStartTime($value)
33: * @method static \Illuminate\Database\Eloquent\Builder|WeekDay
whereStartTimeType($value)
34: * @method static \Illuminate\Database\Eloquent\Builder|WeekDay whereUpdatedAt($value)
35: *
36: * @mixin Eloquent
37: *
38: * @property-read mixed $full_end_time
39: * @property-read mixed $full_start_time
40: * @property-read \App\Models\DoctorSession $doctorSession
41: */
42: class WeekDay extends Model
43: {
44: use HasFactory;
45: public $table = 'session_week_days';
46: public $fillable = [
47: 'doctor_id',
48: 'doctor_session_id',
49: 'day_of_week',
50: 'start_time',
51: 'end_time',
52: 'start_time_type',
53: 'end_time_type',
54: ];
55: /**
56: * The attributes that should be casted to native types.
57: *
58: * @var array
59: */
60: protected $casts = [
61: 'doctor_session_id' => 'integer',
62: 'day' => 'string',
63: 'doctor_id' => 'integer',
64: 'day_of_week' => 'string',
65: 'start_time' => 'string',
66: 'end_time' => 'string',
67: 'start_time_type' => 'string',
68: 'end_time_type' => 'string',
69: ];
70: public function getFullStartTimeAttribute()
71: {
72: return $this->start_time.' '.$this->start_time_type;
73: }
74: public function getFullEndTimeAttribute()
75: {
76: return $this->end_time.' '.$this->end_time_type;
77: }
78: public function doctorSession()
79: {
80: return $this->belongsTo(DoctorSession::class);
81: }
82: }
[app > Models > ZoomOAuth.php]
1: <?php
2: namespace App\Models;
3: use Illuminate\Database\Eloquent\Factories\HasFactory;
4: use Illuminate\Database\Eloquent\Model;
5: class ZoomOAuth extends Model
6: {
7: use HasFactory;
8: protected $table = 'zoom_o_auth_credentials';
9: protected $fillable = [
10: 'user_id',
11: 'access_token',
12: 'refresh_token',
13: ];
14: }
[app > Providers > AppServiceProvider.php]
1: <?php
2: namespace App\Providers;
3: use Illuminate\Pagination\Paginator;
4: use Illuminate\Support\ServiceProvider;
5: use Mariuzzo\LaravelJsLocalization\Commands\LangJsCommand;
6: use Mariuzzo\LaravelJsLocalization\Generators\LangJsGenerator;
7: class AppServiceProvider extends ServiceProvider
8: {
9: /**
10: * Register any application services.
11: */
12: public function register(): void
13: {
14: // Bind the Laravel JS Localization command into the app IOC.
15: $this->app->singleton('localization.js', function ($app) {
16: $app = $this->app;
17: $laravelMajorVersion = (int) $app::VERSION;
18: $files = $app['files'];
19: if ($laravelMajorVersion === 4) {
20: $langs = $app['path.base'].'/app/lang';
21: } elseif ($laravelMajorVersion >= 5 && $laravelMajorVersion < 9) {
22: $langs = $app['path.base'].'/resources/lang';
23: } elseif ($laravelMajorVersion >= 9) {
24: $langs = app()->langPath();
25: }
26: $messages = $app['config']->get('localization-js.messages');
27: $generator = new LangJsGenerator($files, $langs, $messages);
28: return new LangJsCommand($generator);
29: });
30: }
31: /**
32: * Bootstrap any application services.
33: */
34: public function boot(): void
35: {
36: Paginator::useBootstrap();
37: }
38: }
[app > Providers > AuthServiceProvider.php]
1: <?php
2: namespace App\Providers;
3: use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
4: class AuthServiceProvider extends ServiceProvider
5: {
6: /**
7: * The policy mappings for the application.
8: *
9: * @var array
10: */
11: protected $policies = [
12: //
13: ];
14: /**
15: * Register any authentication / authorization services.
16: */
17: public function boot(): void
18: {
19: //
20: }
21: }
[app > Providers > BroadcastServiceProvider.php]
1: <?php
2: namespace App\Providers;
3: use Illuminate\Support\Facades\Broadcast;
4: use Illuminate\Support\ServiceProvider;
5: class BroadcastServiceProvider extends ServiceProvider
6: {
7: /**
8: * Bootstrap any application services.
9: */
10: public function boot(): void
11: {
12: Broadcast::routes();
13: require base_path('routes/channels.php');
14: }
15: }
[app > Providers > EventServiceProvider.php]
1: <?php
2: namespace App\Providers;
3: use App\Events\CreateGoogleAppointment;
4: use App\Events\DeleteAppointmentFromGoogleCalendar;
5: use App\Listeners\HandleCreatedGoogleAppointment;
6: use App\Listeners\HandleDeletedAppointmentFromGoogleCalendar;
7: use Illuminate\Auth\Events\Registered;
8: use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
9: use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
10: class EventServiceProvider extends ServiceProvider
11: {
12: /**
13: * The event listener mappings for the application.
14: *
15: * @var array
16: */
17: protected $listen = [
18: Registered::class => [
19: SendEmailVerificationNotification::class,
20: ],
21: DeleteAppointmentFromGoogleCalendar::class => [
22: HandleDeletedAppointmentFromGoogleCalendar::class,
23: ],
24: CreateGoogleAppointment::class => [
25: HandleCreatedGoogleAppointment::class,
26: ],
27: ];
28: /**
29: * Register any events for your application.
30: */
31: public function boot(): void
32: {
33: //
34: }
35: /**
36: * Determine if events and listeners should be automatically discovered.
37: */
38: public function shouldDiscoverEvents(): bool
39: {
40: return false;
41: }
42: }
[app > Providers > RouteServiceProvider.php]
1: <?php
2: namespace App\Providers;
3: use Illuminate\Cache\RateLimiting\Limit;
4: use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
5: use Illuminate\Http\Request;
6: use Illuminate\Support\Facades\RateLimiter;
7: use Illuminate\Support\Facades\Route;
8: class RouteServiceProvider extends ServiceProvider
9: {
10: /**
11: * The path to the "home" route for your application.
12: *
13: * This is used by Laravel authentication to redirect users after login.
14: *
15: * @var string
16: */
17: public const HOME = 'admin/dashboard';
18: public const PATIENT_HOME = 'patients/dashboard';
19: /**
20: * The controller namespace for the application.
21: *
22: * When present, controller route declarations will automatically be prefixed with
this
23: namespace.
24: *
25: * @var string|null
26: */
27: //
28: /**
29: * Define your route model bindings, pattern filters, etc.
30: */
31: public function boot(): void
32: {
33: RateLimiter::for('api', function (Request $request) {
34: return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
35: });
36: $this->routes(function () {
37: Route::prefix('api')
38: ->middleware('api')
39: ->group(base_path('routes/api.php'));
40: Route::middleware('web')
41: ->group(base_path('routes/web.php'));
42: });
43: }
44: }
[app > Repositories > AppointmentRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Events\CreateGoogleAppointment;
4: use App\Http\Controllers\GoogleCalendarController;
5: use App\Mail\AppointmentBookedMail;
6: use App\Mail\DoctorAppointmentBookMail;
7: use App\Mail\PatientAppointmentBookMail;
8: use App\Models\Appointment;
9: use App\Models\Doctor;
10: use App\Models\Notification;
11: use App\Models\Patient;
12: use App\Models\Service;
13: use App\Models\Transaction;
14: use App\Models\User;
15: use Carbon\Carbon;
16: use Exception;
17: use Illuminate\Support\Arr;
18: use Illuminate\Support\Facades\DB;
19: use Illuminate\Support\Facades\Hash;
20: use Illuminate\Support\Facades\Log;
21: use Illuminate\Support\Facades\Mail;
22: use Illuminate\Support\Str;
23: use Stripe\Checkout\Session;
24: use Stripe\Exception\ApiErrorException;
25: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
26: /**
27: * Class AppointmentRepository
28: *
29: * @version August 3, 2021, 10:37 am UTC
30: */
31: class AppointmentRepository extends BaseRepository
32: {
33: /**
34: * @var GoogleCalendarController
35: */
36: public function __construct(GoogleCalendarController $googleCalendarController)
37: {
38: $this->googleCalendarController = $googleCalendarController;
39: }
40: /**
41: * @var array
42: */
43: protected $fieldSearchable = [
44: ];
45: /**
46: * Return searchable fields
47: */
48: public function getFieldsSearchable(): array
49: {
50: return $this->fieldSearchable;
51: }
52: /**
53: * Configure the Model
54: **/
55: public function model()
56: {
57: return Appointment::class;
58: }
59: /**
60: * @return mixed
61: */
62: public function store($input)
63: {
64: try {
65: DB::beginTransaction();
66: $input['appointment_unique_id'] =
strtoupper(Appointment::generateAppointmentUniqueId());
67: $fromTime = explode(' ', $input['from_time']);
68: $toTime = explode(' ', $input['to_time']);
69: $input['from_time'] = $fromTime[0];
70: $input['from_time_type'] = $fromTime[1];
71: $input['to_time'] = $toTime[0];
72: $input['to_time_type'] = $toTime[1];
73: $input['payment_type'] = Appointment::MANUALLY;
74: $input['payment_method'] = Appointment::MANUALLY;
75: $appointment = Appointment::create($input);
76: $patient = Patient::whereId($input['patient_id'])->with('user')->first();
77: $input['patient_name'] = $patient->user->full_name;
78: $input['original_from_time'] = $fromTime[0].' '.$fromTime[1];
79: $input['original_to_time'] = $toTime[0].' '.$toTime[1];
80: $service = Service::whereId($input['service_id'])->first();
81: $input['service'] = $service->name;
82: if ($patient->user->email_notification) {
83: Mail::to($patient->user->email)->send(new PatientAppointmentBookMail($input));
84: }
85: $input['full_time'] = $input['original_from_time'].'-'.$input['original_to_time'].'
86: '.Carbon::parse($input['date'])->format('jS M, Y');
87: if (! getLogInUser()->hasRole('patient')) {
88: $patientNotification = Notification::create([
89: 'title' => Notification::APPOINTMENT_CREATE_PATIENT_MSG.' '.$input['full_time'],
90: 'type' => Notification::BOOKED,
91: 'user_id' => $patient->user->id,
92: ]);
93: }
94: $doctor = Doctor::whereId($input['doctor_id'])->with('user')->first();
95: $input['doctor_name'] = $doctor->user->full_name;
96: if ($doctor->user->email_notification) {
97: Mail::to($doctor->user->email)->send(new DoctorAppointmentBookMail($input));
98: }
99: $doctorNotification = Notification::create([
100: 'title' => $patient->user->full_name.'
'.Notification::APPOINTMENT_CREATE_DOCTOR_MSG.'
101: '.$input['full_time'],
102: 'type' => Notification::BOOKED,
103: 'user_id' => $doctor->user->id,
104: ]);
105: DB::commit();
106: try {
107: CreateGoogleAppointment::dispatch(true, $appointment->id);
108: CreateGoogleAppointment::dispatch(false, $appointment->id);
109: } catch (Exception $exception) {
110: Log::error($exception->getMessage());
111: }
112: return $appointment;
113: } catch (Exception $e) {
114: DB::rollBack();
115: throw new UnprocessableEntityHttpException($e->getMessage());
116: }
117: }
118: /**
119: * @return mixed
120: */
121: public function frontSideStore($input)
122: {
123: try {
124: DB::beginTransaction();
125: $oldUser = User::whereEmail($input['email'])->first();
126: if (isset($input['is_patient_account']) && $input['is_patient_account'] == 1) {
127: if (! $oldUser) {
128: throw new
UnprocessableEntityHttpException(__('messages.common.email_not_register'));
129: }
130: $input['patient_id'] = $oldUser->patient->id;
131: } else {
132: if ($oldUser) {
133: throw new
UnprocessableEntityHttpException(__('messages.common.email_already_exist'));
134: }
135: $input['original_password'] = Str::random(8);
136: $input['type'] = User::PATIENT;
137: $userFields = ['first_name', 'last_name', 'email', 'password', 'type',
'region_code',
138: 'contact', 'email_verified_at'];
139: $input['email_verified_at'] = Carbon::now();
140: $input['password'] = Hash::make($input['original_password']);
141: /** @var User $user */
142: $user = User::create(Arr::only($input, $userFields));
143: $patientArray['patient_unique_id'] = strtoupper(Patient::generatePatientUniqueId());
144: /** @var Patient $patient */
145: $patient = $user->patient()->create($patientArray);
146: $user->assignRole('patient');
147: $input['patient_id'] = $patient->id;
148: }
149: $input['appointment_unique_id'] =
strtoupper(Appointment::generateAppointmentUniqueId());
150: $input['original_from_time'] = $input['from_time'];
151: $input['original_to_time'] = $input['to_time'];
152: $fromTime = explode(' ', $input['from_time']);
153: $toTime = explode(' ', $input['to_time']);
154: $input['from_time'] = $fromTime[0];
155: $input['from_time_type'] = $fromTime[1];
156: $input['to_time'] = $toTime[0];
157: $input['to_time_type'] = $toTime[1];
158: $input['status'] = Appointment::BOOKED;
159: $input['payment_type'] = Appointment::MANUALLY;
160: $appointment = Appointment::create($input);
161: Mail::to($input['email'])->send(new AppointmentBookedMail($input));
162: $patientFullName = (isset($input['is_patient_account']) &&
$input['is_patient_account'] ==
163: 1) ? $oldUser->full_name : $user->full_name;
164: $patientId = (isset($input['is_patient_account']) && $input['is_patient_account'] ==
1) ?
165: $oldUser->id : $user->id;
166: $input['full_time'] = $input['original_from_time'].'-'.$input['original_to_time'].'
167: '.\Carbon\Carbon::parse($input['date'])->format('jS M, Y');
168: if (getLogInUser() && ! getLogInUser()->hasRole('patient')) {
169: $patientNotification = Notification::create([
170: 'title' => Notification::APPOINTMENT_CREATE_PATIENT_MSG.' '.$input['full_time'],
171: 'type' => Notification::BOOKED,
172: 'user_id' => $patientId,
173: ]);
174: }
175: $doctor = Doctor::whereId($input['doctor_id'])->with('user')->first();
176: $input['doctor_name'] = $doctor->user->full_name;
177: $input['patient_name'] = $patientFullName;
178: $service = Service::whereId($input['service_id'])->first();
179: $input['service'] = $service->name;
180: if ($doctor->user->email_notification) {
181: Mail::to($doctor->user->email)->send(new DoctorAppointmentBookMail($input));
182: }
183: $doctorNotification = Notification::create([
184: 'title' => $patientFullName.' '.Notification::APPOINTMENT_CREATE_DOCTOR_MSG.'
185: '.$input['full_time'],
186: 'type' => Notification::BOOKED,
187: 'user_id' => $doctor->user->id,
188: ]);
189: DB::commit();
190: return $appointment;
191: } catch (Exception $e) {
192: DB::rollBack();
193: throw new UnprocessableEntityHttpException($e->getMessage());
194: }
195: }
196: public function getData(): array
197: {
198: $data['doctors'] = Doctor::with('user')->get()->where('user.status',
199: User::ACTIVE)->pluck('user.full_name',
200: 'id');
201: $data['patients'] = Patient::with('user')->get()->pluck('user.full_name', 'id');
202: $data['patientStatus'] = Appointment::PATIENT_STATUS;
203: $data['services'] = Service::whereStatus(Service::ACTIVE)->pluck('name', 'id');
204: return $data;
205: }
206: public function getDetail($input): array
207: {
208: $input = Appointment::with(['patient.user', 'patient.address', 'doctor.user',
209: 'services'])->where('id',
210: $input->id)->first();
211: $data['name'] = $input->patient->user->full_name;
212: $data['profile'] = $input->patient->profile;
213: $data['Id'] = $input->patient->patient_unique_id;
214: $data['email'] = $input->patient->user->email;
215: $data['address_one'] = $input->patient->address->address1;
216: $data['address_two'] = $input->patient->address->address2;
217: $data['dob'] = $input->patient->user->dob;
218: $data['contact'] = $input->patient->user->contact;
219: $data['gender'] = $input->patient->user->gender;
220: $data['blood_group'] = $input->patient->user->blood_group;
221: $data['from_time'] = $input->from_time;
222: $data['to_time'] = $input->to_time;
223: $data['description'] = $input->discription;
224: $data['doctor'] = $input->doctor->user->full_name;
225: $data['service'] = $input->services->name;
226: $data['count'] = $input->count();
227: $data['date'] = $input->date;
228: return $data;
229: }
230: public function getAppointmentsData(): array
231: {
232: $doctorId = getLogInUser()->doctor->id;
233: /** @var Appointment $appointment */
234: $appointments = Appointment::with(['patient.user', 'user'])->where('doctor_id',
235: $doctorId)->get();
236: $data = [];
237: $count = 0;
238: foreach ($appointments as $key => $appointment) {
239: $startTime = $appointment->from_time.' '.$appointment->from_time_type;
240: $endTime = $appointment->to_time.' '.$appointment->to_time_type;
241: $start = Carbon::createFromFormat('Y-m-d h:i A', $appointment->date.' '.$startTime);
242: $end = Carbon::createFromFormat('Y-m-d h:i A', $appointment->date.' '.$endTime);
243: $data[$key]['id'] = $appointment->id;
244: $data[$key]['title'] = $startTime.'-'.$endTime;
245: $data[$key]['patientName'] = $appointment->patient->user->full_name;
246: $data[$key]['start'] = $start->toDateTimeString();
247: $data[$key]['description'] = $appointment->description;
248: $data[$key]['status'] = $appointment->status;
249: $data[$key]['amount'] = $appointment->payable_amount;
250: $data[$key]['uId'] = $appointment->appointment_unique_id;
251: $data[$key]['service'] = $appointment->services->name;
252: $data[$key]['end'] = $end->toDateTimeString();
253: $data[$key]['color'] = '#FFF';
254: $data[$key]['className'] = [getStatusClassName($appointment->status), 'text-white'];
255: }
256: return $data;
257: }
258: public function getPatientAppointmentsCalendar(): array
259: {
260: $patientId = getLogInUser()->patient->id;
261: /** @var Appointment $appointment */
262: $appointments = Appointment::with(['doctor.user', 'user'])->where('patient_id',
263: $patientId)->get();
264: $data = [];
265: $count = 0;
266: foreach ($appointments as $key => $appointment) {
267: $startTime = $appointment->from_time.' '.$appointment->from_time_type;
268: $endTime = $appointment->to_time.' '.$appointment->to_time_type;
269: $start = Carbon::createFromFormat('Y-m-d h:i A', $appointment->date.' '.$startTime);
270: $end = Carbon::createFromFormat('Y-m-d h:i A', $appointment->date.' '.$endTime);
271: $data[$key]['id'] = $appointment->id;
272: $data[$key]['title'] = $startTime.'-'.$endTime;
273: $data[$key]['doctorName'] = $appointment->doctor->user->full_name;
274: $data[$key]['start'] = $start->toDateTimeString();
275: $data[$key]['description'] = $appointment->description;
276: $data[$key]['status'] = $appointment->status;
277: $data[$key]['amount'] = $appointment->payable_amount;
278: $data[$key]['uId'] = $appointment->appointment_unique_id;
279: $data[$key]['service'] = $appointment->services->name;
280: $data[$key]['end'] = $end->toDateTimeString();
281: $data[$key]['color'] = '#FFF';
282: $data[$key]['className'] = [getStatusClassName($appointment->status), 'text-white'];
283: }
284: return $data;
285: }
286: public function getCalendar(): array
287: {
288: /** @var Appointment $appointment */
289: $appointments = Appointment::with(['doctor.user', 'user'])->get();
290: $data = [];
291: $count = 0;
292: foreach ($appointments as $key => $appointment) {
293: $startTime = $appointment->from_time.' '.$appointment->from_time_type;
294: $endTime = $appointment->to_time.' '.$appointment->to_time_type;
295: $start = Carbon::createFromFormat('Y-m-d h:i A', $appointment->date.' '.$startTime);
296: $end = Carbon::createFromFormat('Y-m-d h:i A', $appointment->date.' '.$endTime);
297: $data[$key]['id'] = $appointment->id;
298: $data[$key]['title'] = $startTime.'-'.$endTime;
299: $data[$key]['doctorName'] = $appointment->doctor->user->full_name;
300: $data[$key]['patient'] = $appointment->patient->user->full_name;
301: $data[$key]['start'] = $start->toDateTimeString();
302: $data[$key]['description'] = $appointment->description;
303: $data[$key]['status'] = $appointment->status;
304: $data[$key]['amount'] = $appointment->payable_amount;
305: $data[$key]['uId'] = $appointment->appointment_unique_id;
306: $data[$key]['service'] = $appointment->services->name;
307: $data[$key]['end'] = $end->toDateTimeString();
308: $data[$key]['color'] = '#FFF';
309: $data[$key]['className'] = [getStatusClassName($appointment->status), 'text-white'];
310: }
311: return $data;
312: }
313: public function showAppointment($input): array
314: {
315: $data['data'] = Appointment::with(['patient.user', 'doctor.user',
316: 'services'])->findOrFail($input['id']);
317: $data['transactionStatus'] =
318: Transaction::whereAppointmentId($data['data']->appointment_unique_id)->exists();
319: return $data;
320: }
321: public function showDoctorAppointment($appointment): array
322: {
323: $data['data'] = Appointment::with(['patient.user', 'doctor.user',
324: 'services'])->findOrFail($appointment->id);
325: return $data;
326: }
327: /**
328: * @return mixed
329: *
330: * @throws ApiErrorException
331: */
332: public function createSession($input)
333: {
334: $appointmentId = $input['appointment_unique_id'];
335: $patientEmail = Patient::with('user')->whereId($input['patient_id'])->first();
336: $doctorName = Doctor::with('user')->whereId($input['doctor_id'])->first();
337: setStripeApiKey();
338: $successUrl = '/medical-payment-success';
339: $cancelUrl = '/medical-payment-failed';
340: $session = Session::create([
341: 'payment_method_types' => ['card'],
342: 'customer_email' => $patientEmail->user->email,
343: 'line_items' => [
344: [
345: 'price_data' => [
346: 'product_data' => [
347: 'name' => 'Payment for appointment booking',
348: ],
349: 'unit_amount' => in_array(getCurrencyCode(), zeroDecimalCurrencies()) ?
350: $input['payable_amount'] : $input['payable_amount'] * 100,
351: 'currency' => getCurrencyCode(),
352: ],
353: 'quantity' => 1,
354: 'description' => 'Payment for booking appointment with doctor :
355: '.$doctorName->user->full_name.' at '.Carbon::parse($input->date)->format('d/m/Y').'
356: '.$input->from_time.' '.$input->from_time_type.' to '.$input->to_time.'
357: '.$input->to_time_type,
358: ],
359: ],
360: 'client_reference_id' => $appointmentId,
361: 'mode' => 'payment',
362: 'success_url' => url($successUrl).'?session_id={CHECKOUT_SESSION_ID}',
363: 'cancel_url' => url($cancelUrl.'?error=payment_cancelled'),
364: ]);
365: $result = [
366: 'sessionId' => $session['id'],
367: ];
368: return $result;
369: }
370: }
[app > Repositories > BaseRepository.php]
1: <?php
2: namespace App\Repositories;
3: use Exception;
4: use Illuminate\Container\Container as Application;
5: use Illuminate\Database\Eloquent\Builder;
6: use Illuminate\Database\Eloquent\Collection;
7: use Illuminate\Database\Eloquent\Model;
8: abstract class BaseRepository
9: {
10: /**
11: * @var Model
12: */
13: protected $model;
14: /**
15: * @var Application
16: */
17: protected $app;
18: /**
19: * @throws \Exception
20: */
21: public function __construct(Application $app)
22: {
23: $this->app = $app;
24: $this->makeModel();
25: }
26: /**
27: * Get searchable fields array
28: *
29: * @return array
30: */
31: abstract public function getFieldsSearchable();
32: /**
33: * Configure the Model
34: *
35: * @return string
36: */
37: abstract public function model();
38: /**
39: * Make Model instance
40: *
41: * @return Model
42: *
43: * @throws \Exception
44: */
45: public function makeModel()
46: {
47: $model = $this->app->make($this->model());
48: if (! $model instanceof Model) {
49: throw new \Exception("Class {$this->model()} must be an instance of
50: Illuminate\\Database\\Eloquent\\Model");
51: }
52: return $this->model = $model;
53: }
54: /**
55: * Paginate records for scaffold.
56: *
57: * @param int $perPage
58: * @param array $columns
59: * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
60: */
61: public function paginate($perPage, $columns = ['*'])
62: {
63: $query = $this->allQuery();
64: return $query->paginate($perPage, $columns);
65: }
66: /**
67: * Build a query for retrieving all records.
68: *
69: * @param array $search
70: * @param int|null $skip
71: * @param int|null $limit
72: * @return Builder
73: */
74: public function allQuery($search = [], $skip = null, $limit = null)
75: {
76: $query = $this->model->newQuery();
77: if (count($search)) {
78: foreach ($search as $key => $value) {
79: if (in_array($key, $this->getFieldsSearchable())) {
80: $query->where($key, $value);
81: }
82: }
83: }
84: if (! is_null($skip)) {
85: $query->skip($skip);
86: }
87: if (! is_null($limit)) {
88: $query->limit($limit);
89: }
90: return $query;
91: }
92: /**
93: * Retrieve all records with given filter criteria
94: *
95: * @param array $search
96: * @param int|null $skip
97: * @param int|null $limit
98: * @param array $columns
99: * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator|Builder[]|Collection
100: */
101: public function all($search = [], $skip = null, $limit = null, $columns = ['*'])
102: {
103: $query = $this->allQuery($search, $skip, $limit);
104: return $query->get($columns);
105: }
106: /**
107: * Create model record
108: *
109: * @param array $input
110: * @return Model
111: */
112: public function create($input)
113: {
114: $model = $this->model->newInstance($input);
115: $model->save();
116: return $model;
117: }
118: /**
119: * Find model record for given id
120: *
121: * @param int $id
122: * @param array $columns
123: * @return Builder|Builder[]|Collection|Model|null
124: */
125: public function find($id, $columns = ['*'])
126: {
127: $query = $this->model->newQuery();
128: return $query->find($id, $columns);
129: }
130: /**
131: * Update model record for given id
132: *
133: * @param array $input
134: * @param int $id
135: * @return Builder|Builder[]|Collection|Model
136: */
137: public function update($input, $id)
138: {
139: $query = $this->model->newQuery();
140: $model = $query->findOrFail($id);
141: $model->fill($input);
142: $model->save();
143: return $model;
144: }
145: /**
146: * @param int $id
147: * @return bool|mixed|null
148: *
149: * @throws Exception
150: */
151: public function delete($id)
152: {
153: $query = $this->model->newQuery();
154: $model = $query->findOrFail($id);
155: return $model->delete();
156: }
157: /**
158: * @param int $id
159: * @param array $columns
160: * @return mixed
161: */
162: public function findWithoutFail($id, $columns = ['*'])
163: {
164: try {
165: return $this->find($id, $columns);
166: } catch (Exception $e) {
167: return;
168: }
169: }
170: }
[app > Repositories > BrandRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Brand;
4: /**
5: * Class BrandRepository
6: *
7: * @version February 13, 2020, 4:28 am UTC
8: */
9: class BrandRepository extends BaseRepository
10: {
11: /**
12: * @var array
13: */
14: protected $fieldSearchable = [
15: 'name',
16: 'seller',
17: 'email',
18: 'phone',
19: ];
20: /**
21: * Return searchable fields
22: */
23: public function getFieldsSearchable(): array
24: {
25: return $this->fieldSearchable;
26: }
27: /**
28: * Configure the Model
29: **/
30: public function model()
31: {
32: return Brand::class;
33: }
34: }
[app > Repositories > CategoryRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Category;
4: /**
5: * Class CategoryRepository
6: *
7: * @version February 6, 2020, 3:16 am UTC
8: */
9: class CategoryRepository extends BaseRepository
10: {
11: /**
12: * @var array
13: */
14: protected $fieldSearchable = [
15: 'name',
16: ];
17: /**
18: * Return searchable fields
19: */
20: public function getFieldsSearchable(): array
21: {
22: return $this->fieldSearchable;
23: }
24: /**
25: * Configure the Model
26: **/
27: public function model()
28: {
29: return Category::class;
30: }
31: }
[app > Repositories > CityRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\City;
4: /**
5: * Class CityRepository
6: *
7: * @version July 31, 2021, 7:41 am UTC
8: */
9: class CityRepository extends BaseRepository
10: {
11: /**
12: * @var array
13: */
14: protected $fieldSearchable = [
15: 'name',
16: 'state_id',
17: ];
18: /**
19: * Return searchable fields
20: */
21: public function getFieldsSearchable(): array
22: {
23: return $this->fieldSearchable;
24: }
25: /**
26: * Configure the Model
27: **/
28: public function model()
29: {
30: return City::class;
31: }
32: }
[app > Repositories > CountryRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Country;
4: /**
5: * Class CountryRepository
6: *
7: * @version July 29, 2021, 10:49 am UTC
8: */
9: class CountryRepository extends BaseRepository
10: {
11: /**
12: * @var array
13: */
14: protected $fieldSearchable = [
15: 'name',
16: 'short_code',
17: ];
18: /**
19: * Return searchable fields
20: */
21: public function getFieldsSearchable(): array
22: {
23: return $this->fieldSearchable;
24: }
25: /**
26: * Configure the Model
27: **/
28: public function model()
29: {
30: return Country::class;
31: }
32: }
[app > Repositories > CurrencyRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Currency;
4: use Illuminate\Database\Eloquent\Builder;
5: /**
6: * Class CurrencyRepository
7: *
8: * @version August 26, 2021, 6:57 am UTC
9: */
10: class CurrencyRepository extends BaseRepository
11: {
12: /**
13: * @var array
14: */
15: protected $fieldSearchable = [
16: 'currency_name',
17: 'currency_icon',
18: 'currency_code',
19: ];
20: /**
21: * Return searchable fields
22: */
23: public function getFieldsSearchable(): array
24: {
25: return $this->fieldSearchable;
26: }
27: /**
28: * Configure the Model
29: **/
30: public function model()
31: {
32: return Currency::class;
33: }
34: /**
35: * @return mixed
36: */
37: public function store($input)
38: {
39: $input['currency_code'] = strtoupper($input['currency_code']);
40: $currency = Currency::create($input);
41: return $currency;
42: }
43: /**
44: * @return Builder|Currency
45: */
46: public function update($input, $id)
47: {
48: $input['currency_code'] = strtoupper($input['currency_code']);
49: $currency = Currency::whereId($id);
50: $currency->update([
51: 'currency_code' => $input['currency_code'],
52: 'currency_icon' => $input['currency_icon'],
53: 'currency_name' => $input['currency_name'],
54: ]);
55: return $currency;
56: }
57: }
[app > Repositories > DashboardRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Appointment;
4: use App\Models\Doctor;
5: use App\Models\Patient;
6: use App\Models\Service;
7: use App\Models\ServiceCategory;
8: use App\Models\User;
9: use Carbon\Carbon;
10: use Illuminate\Support\Facades\DB;
11: /**
12: * Class CityRepository
13: *
14: * @version July 31, 2021, 7:41 am UTC
15: */
16: class DashboardRepository
17: {
18: //admin
19: public function getData(): array
20: {
21: $data['patients'] = Patient::with(['user', 'appointments'])
22: ->withCount('appointments')
23: ->whereRaw('Date(created_at) = CURDATE()')
24: ->orderBy('created_at', 'DESC')
25: ->paginate(5);
26: $data['totalDoctorCount'] = User::toBase()->whereType(User::DOCTOR)->where('status',
27: User::ACTIVE)->count();
28: $data['totalPatientCount'] = User::toBase()->whereType(User::PATIENT)->count();
29: $data['todayAppointmentCount'] = Appointment::toBase()->where('date',
30: Carbon::now()->format('Y-m-d'))->whereStatus(Appointment::BOOKED)->count();
31: $data['totalRegisteredPatientCount'] =
32: User::toBase()->whereType(User::PATIENT)->whereRaw('Date(created_at) =
33: CURDATE()')->count();
34: $data['servicesArr'] = Service::toBase()->whereStatus(true)->pluck('name',
35: 'id')->toArray();
36: $data['serviceCategoriesArr'] = ServiceCategory::toBase()->pluck('name',
'id')->toArray();
37: $data['doctorArr'] = Doctor::with('user')->get()->pluck('user.full_name',
38: 'id')->toArray();
39: return $data;
40: }
41: //Doctor
42: /**
43: * @return mixed
44: */
45: public function getDoctorData()
46: {
47: $doctorId = getLogInUser()->doctor->id;
48: $todayDate = Carbon::now()->format('Y-m-d');
49: $appointments['records'] = Appointment::with(['patient.user'])
50: ->where('doctor_id', $doctorId)
51: ->whereStatus(Appointment::BOOKED)
52: ->whereDate('date', Carbon::today())
53: ->orderBy('date', 'ASC')
54: ->paginate(5);
55: $appointments['totalAppointmentCount'] =
56: Appointment::whereDoctorId($doctorId)->whereNotIn('status',
57: [Appointment::CANCELLED])->count();
58: $appointments['todayAppointmentCount'] =
59: Appointment::whereDoctorId($doctorId)->where('date', '=',
60: $todayDate)->whereNotIn('status', [Appointment::CANCELLED])->count();
61: $appointments['upcomingAppointmentCount'] =
62: Appointment::whereDoctorId($doctorId)->where('date', '>',
63: $todayDate)->whereStatus(Appointment::BOOKED)->count();
64: return $appointments;
65: }
66: //admin
67: public function patientData($input)
68: {
69: if (isset($input['day'])) {
70: $data = Patient::with(['user', 'appointments'])
71: ->withCount('appointments')
72: ->whereRaw('Date(created_at) = CURDATE()')
73: ->orderBy('created_at', 'DESC')
74: ->paginate(5);
75: return $data;
76: }
77: if (isset($input['week'])) {
78: $now = Carbon::now();
79: $weekStartDate = $now->startOfWeek()->format('Y-m-d H:i');
80: $weekEndDate = $now->endOfWeek()->format('Y-m-d H:i');
81: $data = Patient::with(['user', 'appointments'])
82: ->withCount('appointments')
83: ->whereBetween('created_at', [$weekStartDate, $weekEndDate])
84: ->orderBy('created_at', 'DESC')
85: ->paginate(5);
86: return $data;
87: }
88: if (isset($input['month'])) {
89: $data = Patient::with(['user', 'appointments'])
90: ->withCount('appointments')
91: ->whereMonth('created_at', Carbon::now()->month)
92: ->orderBy('created_at', 'DESC')
93: ->paginate(5);
94: return $data;
95: }
96: }
97: //doctor
98: /**
99: * @return mixed
100: */
101: public function doctorAppointment($input)
102: {
103: $doctorId = getLogInUser()->doctor->id;
104: if (isset($input['day'])) {
105: $data = Appointment::with(['patient.user', 'user', 'services'])
106: ->where('doctor_id', $doctorId)
107: ->whereStatus(Appointment::BOOKED)
108: ->whereDate('date', Carbon::today())
109: ->orderBy('date', 'ASC')
110: ->paginate(10);
111: return $data;
112: }
113: if (isset($input['week'])) {
114: $now = Carbon::now();
115: $weekStartDate = $now->startOfWeek()->format('Y-m-d');
116: $weekEndDate = $now->endOfWeek()->format('Y-m-d');
117: $data = Appointment::with(['patient.user', 'user', 'services'])
118: ->where('doctor_id', $doctorId)
119: ->whereStatus(Appointment::BOOKED)
120: ->whereBetween('date', [$weekStartDate, $weekEndDate])
121: ->orderBy('date', 'ASC')
122: ->paginate(10);
123: return $data;
124: }
125: if (isset($input['month'])) {
126: $data = Appointment::with(['patient.user', 'user', 'services'])
127: ->where('doctor_id', $doctorId)
128: ->whereStatus(Appointment::BOOKED)
129: ->whereMonth('date', Carbon::now()->month)
130: ->orderBy('date', 'ASC')
131: ->paginate(10);
132: return $data;
133: }
134: }
135: public function getPatientData(): array
136: {
137: $todayDate = Carbon::now()->format('Y-m-d');
138: $patientId = getLogInUser()->patient->id;
139: $todayCompleted = Appointment::wherePatientId($patientId)->where('date', '=',
140: $todayDate)->whereStatus(Appointment::CHECK_OUT)->count();
141: $data['todayAppointmentCount'] =
Appointment::wherePatientId($patientId)->where('date',
142: '=',
143: $todayDate)->count();
144: $data['upcomingAppointmentCount'] =
Appointment::wherePatientId($patientId)->where('date',
145: '>',
146: $todayDate)->whereNotIn('status', [Appointment::CANCELLED])->count();
147: $data['pastCompletedAppointmentCount'] =
148: Appointment::wherePatientId($patientId)->where('date', '<',
149: $todayDate)->count();
150: $data['completedAppointmentCount'] = $data['pastCompletedAppointmentCount'] +
151: $todayCompleted;
152: $data['todayAppointment'] = Appointment::with(['patient.user', 'doctor.user',
'services'])
153: ->wherePatientId($patientId)
154: ->whereStatus(Appointment::BOOKED)
155: ->where('date', '=', $todayDate)
156: ->orderBy('created_at', 'DESC')
157: ->paginate(10);
158: $data['upcomingAppointment'] = Appointment::with(['patient.user', 'doctor.user',
159: 'services'])
160: ->wherePatientId($patientId)
161: ->whereStatus(Appointment::BOOKED)
162: ->where('date', '>', $todayDate)
163: ->paginate(10);
164: return $data;
165: }
166: public function getAppointmentChartData($input): array
167: {
168: $appointments = Appointment::with('services')->whereYear('created_at',
169: Carbon::now()->year)
170: ->select(DB::raw('MONTH(created_at) as month,appointments.*'))->get();
171: $months = [
172: 1 => __('messages.months.jan'),
173: 2 => __('messages.months.feb'),
174: 3 => __('messages.months.mar'),
175: 4 => __('messages.months.apr'),
176: 5 => __('messages.months.may'),
177: 6 => __('messages.months.jun'),
178: 7 => __('messages.months.jul'),
179: 8 => __('messages.months.aug'),
180: 9 => __('messages.months.sep'),
181: 10 => __('messages.months.oct'),
182: 11 => __('messages.months.nov'),
183: 12 => __('messages.months.dec'),
184: ];
185: $monthWiseRecords = [];
186: $serviceId = ! empty($input['serviceId']) ? $input['serviceId'] : '';
187: $doctorId = ! empty($input['dashboardDoctorId']) ? $input['dashboardDoctorId'] : '';
188: $serviceCategoryId = ! empty($input['serviceCategoryId']) ?
$input['serviceCategoryId'] :
189: '';
190: foreach ($months as $month => $monthName) {
191: $monthWiseRecords[$monthName] = $appointments->where('month', $month)
192: ->where('status', Appointment::CHECK_OUT)
193: ->when($serviceId, function ($query, $serviceId) {
194: return $query->where('service_id', $serviceId);
195: })
196: ->when($doctorId, function ($query, $doctorId) {
197: return $query->where('doctor_id', $doctorId);
198: })
199: ->when($serviceCategoryId, function ($query, $serviceCategoryId) {
200: return $query->where('services.category_id', $serviceCategoryId);
201: })
202: ->sum('payable_amount');
203: }
204: return $monthWiseRecords;
205: }
206: }
[app > Repositories > DoctorSessionRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Doctor;
4: use App\Models\DoctorSession;
5: use App\Models\User;
6: use Carbon\Carbon;
7: use DateTime;
8: use Illuminate\Support\Arr;
9: use Illuminate\Support\Collection;
10: use Illuminate\Support\Facades\DB;
11: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
12: /**
13: * Class DoctorSessionRepository
14: *
15: * @version July 31, 2021, 6:04 am UTC
16: */
17: class DoctorSessionRepository extends BaseRepository
18: {
19: /**
20: * @var array
21: */
22: protected $fieldSearchable = [
23: 'session_time',
24: ];
25: /**
26: * Return searchable fields
27: */
28: public function getFieldsSearchable(): array
29: {
30: return $this->fieldSearchable;
31: }
32: /**
33: * Configure the Model
34: **/
35: public function model()
36: {
37: return DoctorSession::class;
38: }
39: public function getSyncList(): Collection
40: {
41: if (getLogInUser()->hasRole('doctor')) {
42: return Doctor::toBase()->where('user_id',
43: getLogInUserId())->get()->pluck('user.full_name', 'id');
44: }
45: return Doctor::with('user')->whereNotIn('id',
46: DoctorSession::pluck('doctor_id')->toArray())->get()->where('user.status',
47: User::ACTIVE)->pluck('user.full_name', 'id');
48: }
49: /**
50: * @return array|bool[]|false
51: */
52: public function store($input)
53: {
54: try {
55: DB::beginTransaction();
56: /** @var DoctorSession $doctorSession */
57: $doctorSession = DoctorSession::create(Arr::only($input,
58: app(DoctorSession::class)->getFillable()));
59: $result['success'] = true;
60: if (! empty($input['checked_week_days']) && count($input['checked_week_days']) > 0) {
61: foreach ($input['checked_week_days'] as $day) {
62: $exists = DB::table('session_week_days')
63: ->where('doctor_id', $input['doctor_id'])
64: ->where('day_of_week', $day)
65: ->exists();
66: if ($exists) {
67: return false;
68: }
69: $result = $this->validateSlotTiming($input, $day);
70: if (! $result['success']) {
71: return $result;
72: }
73: $this->saveSlots($input, $day, $doctorSession);
74: }
75: }
76: DB::commit();
77: return $result;
78: } catch (\Exception $e) {
79: throw new UnprocessableEntityHttpException($e->getMessage());
80: }
81: }
82: /**
83: * @return array|bool[]
84: */
85: public function updateDoctorSession(array $input, DoctorSession $doctorSession)
86: {
87: try {
88: DB::beginTransaction();
89: $doctorId = $doctorSession->doctor_id;
90: $doctorSession->update($input);
91: $result['success'] = true;
92: $doctorSession->sessionWeekDays()->delete();
93: if (! empty($input['checked_week_days'])) {
94: foreach ($input['checked_week_days'] as $day) {
95: $result = $this->validateSlotTiming($input, $day);
96: if (! $result['success']) {
97: return $result;
98: }
99: $this->saveSlots($input, $day, $doctorSession);
100: }
101: }
102: DB::commit();
103: return $result;
104: } catch (\Exception $e) {
105: throw new UnprocessableEntityHttpException($e->getMessage());
106: }
107: }
108: public function saveSlots($input, $day, $doctorSession): bool
109: {
110: /** @var DoctorSession $doctorSession */
111: $startTimeArr = $input['startTimes'][$day] ?? [];
112: $endTimeArr = $input['endTimes'][$day] ?? [];
113: if (count($startTimeArr) != 0 && count($endTimeArr) != 0) {
114: foreach ($startTimeArr as $key => $startTime) {
115: $startTimeData = explode(' ', $startTime);
116: $endTimeData = explode(' ', $endTimeArr[$key]);
117: $doctorSession->sessionWeekDays()->create([
118: 'doctor_id' => $doctorSession->doctor_id,
119: 'doctor_session_id' => $doctorSession->id,
120: 'day_of_week' => $day,
121: 'start_time' => $startTimeData[0],
122: 'start_time_type' => $startTimeData[1],
123: 'end_time' => $endTimeData[0],
124: 'end_time_type' => $endTimeData[1],
125: ]);
126: }
127: }
128: return true;
129: }
130: public function validateSlotTiming($input, $day)
131: {
132: $startTimeArr = $input['startTimes'][$day] ?? [];
133: $endTimeArr = $input['endTimes'][$day] ?? [];
134: foreach ($startTimeArr as $key => $startTime) {
135: $slotStartTime = Carbon::instance(DateTime::createFromFormat('h:i A', $startTime));
136: $tempArr = Arr::except($startTimeArr, [$key]);
137: foreach ($tempArr as $tempKey => $tempStartTime) {
138: $start = Carbon::instance(DateTime::createFromFormat('h:i A', $tempStartTime));
139: $end = Carbon::instance(DateTime::createFromFormat('h:i A', $endTimeArr[$tempKey]));
140: if ($slotStartTime->isBetween($start, $end)) {
141: return ['day' => $day, 'startTime' => $startTime, 'success' => false, 'key' =>
$key];
142: }
143: }
144: }
145: return ['success' => true];
146: }
147: }
[app > Repositories > FaqRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Faq;
4: /**
5: * Class FaqRepository
6: *
7: * @version September 21, 2021, 12:51 pm UTC
8: */
9: class FaqRepository extends BaseRepository
10: {
11: /**
12: * @var array
13: */
14: protected $fieldSearchable = [
15: ];
16: /**
17: * Return searchable fields
18: */
19: public function getFieldsSearchable(): array
20: {
21: return $this->fieldSearchable;
22: }
23: /**
24: * Configure the Model
25: **/
26: public function model()
27: {
28: return Faq::class;
29: }
30: }
[app > Repositories > FrontPatientTestimonialRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\FrontPatientTestimonial;
4: use Exception;
5: use Illuminate\Support\Facades\DB;
6: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
7: /**
8: * Class FrontPatientTestimonialRepository
9: *
10: * @version September 22, 2021, 11:20 am UTC
11: */
12: class FrontPatientTestimonialRepository extends BaseRepository
13: {
14: /**
15: * @var array
16: */
17: protected $fieldSearchable = [
18: 'name',
19: 'designation',
20: 'short_description',
21: ];
22: /**
23: * Return searchable fields
24: */
25: public function getFieldsSearchable(): array
26: {
27: return $this->fieldSearchable;
28: }
29: /**
30: * Configure the Model
31: **/
32: public function model()
33: {
34: return FrontPatientTestimonial::class;
35: }
36: public function store($input): bool
37: {
38: try {
39: DB::beginTransaction();
40: $slider = FrontPatientTestimonial::create($input);
41: if (isset($input['profile']) && ! empty($input['profile'])) {
42:
43: $slider->addMedia($input['profile'])->toMediaCollection(FrontPatientTestimonial::FRON
T_PATIENT_PROFILE,
44: config('app.media_disc'));
45: }
46: DB::commit();
47: return true;
48: } catch (Exception $e) {
49: DB::rollBack();
50: throw new UnprocessableEntityHttpException($e->getMessage());
51: }
52: }
53: public function update($input, $id): bool
54: {
55: try {
56: DB::beginTransaction();
57: $slider = FrontPatientTestimonial::findOrFail($id);
58: $slider->update($input);
59: if (isset($input['profile']) && ! empty($input['profile'])) {
60: $slider->clearMediaCollection(FrontPatientTestimonial::FRONT_PATIENT_PROFILE);
61: $slider->media()->delete();
62:
63: $slider->addMedia($input['profile'])->toMediaCollection(FrontPatientTestimonial::FRON
T_PATIENT_PROFILE,
64: config('app.media_disc'));
65: }
66: DB::commit();
67: return true;
68: } catch (Exception $e) {
69: DB::rollBack();
70: throw new UnprocessableEntityHttpException($e->getMessage());
71: }
72: }
73: }
[app > Repositories > GeneratePatientSmartCardsRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\SmartPatientCards;
4: use App\Models\Patient;
5: use Exception;
6: use Illuminate\Support\Facades\DB;
7: use Illuminate\Support\Facades\Hash;
8: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
9: use App\Models\User;
10: use SimpleSoftwareIO\QrCode\Facades\QrCode;
11: /**
12: * Class StaffRepository
13: *
14: * @version August 6, 2021, 10:17 am UTC
15: */
16: class GeneratePatientSmartCardsRepository extends BaseRepository
17: {
18: /**
19: * @var array
20: */
21: protected $fieldSearchable = [
22: ];
23: public function getFieldsSearchable(): array
24: {
25: return $this->fieldSearchable;
26: }
27: public function model()
28: {
29: return SmartPatientCards::class;
30: }
31: public function store($input)
32: {
33: try {
34: DB::beginTransaction();
35: if($input['status'] == Patient::ALL_PATIENT){
36: Patient::where('user_id','!=',null)->update(['template_id' =>
$input['template_id']]);
37: $all =
Patient::select('id','patient_unique_id')->get()->pluck('patient_unique_id','id');
38: foreach ($all as $key => $value) {
39: Patient::where('id',$key)->update([
40: 'qr_code' => route('patient_show').'/'.$value
41: ]);
42: }
43: }
44: if($input['status'] == Patient::ONLY_ONE_PATIENT){
45: $data = Patient::where('user_id',$input['patient_id'])->first();
46: Patient::where('user_id',$input['patient_id'])->update(['template_id' =>
47: $input['template_id']]);
48: Patient::where('user_id',$input['patient_id'])->update([
49: 'qr_code' => route('patient_show').'/'.$data->patient_unique_id
50: ]);
51: }
52: if($input['status'] == Patient::REMANING_PATIENT){
53: $all =
54: Patient::select('id','patient_unique_id')->where('template_id',null)->get()->pluck('p
atient_unique_id','id');
55: foreach ($all as $key => $value) {
56: Patient::where('id',$key)->update([
57: 'qr_code' => route('patient_show').'/'.$value
58: ]);
59: }
60: Patient::where('template_id',null)->update(['template_id' => $input['template_id']]);
61: }
62: DB::commit();
63: return true;
64: } catch (Exception $e) {
65: DB::rollBack();
66: throw new UnprocessableEntityHttpException($e->getMessage());
67: }
68: }
69: }
[app > Repositories > GoogleCalendarRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\AppointmentGoogleCalendar;
4: use App\Models\GoogleCalendarIntegration;
5: use App\Models\GoogleCalendarList;
6: use App\Models\User;
7: use Carbon\Carbon;
8: use Google_Client;
9: use Google_Service_Calendar;
10: use Google_Service_Calendar_Event;
11: use Illuminate\Support\Facades\Auth;
12: use Illuminate\Support\Facades\Log;
13: /**
14: * Class GoogleCalendarRepository
15: */
16: class GoogleCalendarRepository
17: {
18: public $client;
19: public function __construct()
20: {
21: $this->client = new Google_Client();
22: // Set the application name, this is included in the User-Agent HTTP header.
23: $this->client->setApplicationName(config('app.name'));
24: // Set the authentication credentials we downloaded from Google.
25: if (config('app.google_oauth_path') != '') {
26:
27: $this->client->setAuthConfig(resource_path('google-oath/'.config('app.google_oauth_pa
th')));
28: }
29: // Setting offline here means we can pull data from the venue's calendar when they
are not
30: actively using the site.
31: $this->client->setAccessType('offline');
32: // This will include any other scopes (Google APIs) previously granted by the venue
33: $this->client->setIncludeGrantedScopes(true);
34: // Set this to force to consent form to display.
35: $this->client->setApprovalPrompt('force');
36: // Add the Google Calendar scope to the request.
37: $this->client->addScope(Google_Service_Calendar::CALENDAR);
38: }
39: public function store($appointment, $accessToken, $meta)
40: {
41: $date = $appointment['date'];
42: $timezone = $appointment->doctor->user->time_zone;
43: $timeZone = isset(User::TIME_ZONE_ARRAY[$timezone]) ?
User::TIME_ZONE_ARRAY[$timezone] :
44: null;
45: $startTime = date('H:i', strtotime($appointment['from_time'].'
46: '.$appointment['from_time_type']));
47: $endTime = date('H:i', strtotime($appointment['to_time'].'
48: '.$appointment['to_time_type']));
49: $startDateTime = Carbon::parse($date.' '.$startTime, $timeZone)->toRfc3339String();
50: $endDateTime = Carbon::parse($date.' '.$endTime, $timeZone)->toRfc3339String();
51: $results = [];
52: if ($accessToken) {
53: $this->client->setAccessToken($accessToken);
54: $service = new Google_Service_Calendar($this->client);
55: foreach ($meta['lists'] as $calendarId) {
56: $event = new Google_Service_Calendar_Event([
57: 'summary' => $meta['name'],
58: 'description' => isset($appointment['description']) ? $appointment['description'] :
59: $meta['description'],
60: 'start' => ['dateTime' => $startDateTime],
61: 'end' => ['dateTime' => $endDateTime],
62: 'reminders' => ['useDefault' => true],
63: ]);
64: // Google Meet integration code
65: // $conference = new \Google_Service_Calendar_ConferenceData();
66: // $conferenceRequest = new
\Google_Service_Calendar_CreateConferenceRequest();
67: // $conferenceRequest->setRequestId('randomString123'); // update here the
68: string code
69: // $conference->setCreateRequest($conferenceRequest);
70: // $event->setConferenceData($conference);
71: $data = $service->events->insert($calendarId, $event);
72: $data['google_calendar_id'] = $calendarId;
73: $results[] = $data;
74: }
75: return $results;
76: } else {
77: return $results;
78: }
79: }
80: public function getAccessToken($user)
81: {
82: $accessToken = json_decode($user->gCredentials->meta, true);
83: try {
84: // Refresh the token if it's expired.
85: $this->client->setAccessToken($accessToken);
86: if ($this->client->isAccessTokenExpired()) {
87: Log::info('expired');
88: $accessToken =
89: $this->client->fetchAccessTokenWithRefreshToken($accessToken['refresh_token']);
90: $calendarRecord = GoogleCalendarIntegration::whereUserId($user->id)->first();
91: $calendarRecord->update([
92: 'access_token' => $accessToken['access_token'],
93: 'meta' => json_encode($accessToken),
94: 'last_used_at' => Carbon::now(),
95: ]);
96: }
97: } catch (\Exception $exception) {
98: Log::error($exception->getMessage());
99: }
100: return $accessToken['access_token'];
101: }
102: public function syncCalendarList($user): array
103: {
104: $this->getAccessToken($user);
105: $gcHelper = new Google_Service_Calendar($this->client);
106: // Use the Google Client calendar service. This gives us methods for interacting
107: // with the Google Calendar API
108: $calendarList = $gcHelper->calendarList->listCalendarList();
109: $googleCalendarList = [];
110: $existingCalendars = GoogleCalendarList::whereUserId(Auth::id())
111: ->pluck('google_calendar_id', 'google_calendar_id')
112: ->toArray();
113: foreach ($calendarList->getItems() as $calendarListEntry) {
114: if ($calendarListEntry->accessRole == 'owner') {
115: $exists = GoogleCalendarList::whereUserId(getLogInUserId())
116: ->where('google_calendar_id', $calendarListEntry['id'])
117: ->first();
118: unset($existingCalendars[$calendarListEntry['id']]);
119: if (! $exists) {
120: $googleCalendarList[] = GoogleCalendarList::create([
121: 'user_id' => getLogInUserId(),
122: 'calendar_name' => $calendarListEntry['summary'],
123: 'google_calendar_id' => $calendarListEntry['id'],
124: 'meta' => json_encode($calendarListEntry),
125: ]);
126: }
127: }
128: }
129: AppointmentGoogleCalendar::whereIn('google_calendar_id',
$existingCalendars)->delete();
130: GoogleCalendarList::whereIn('google_calendar_id', $existingCalendars)->delete();
131: return $googleCalendarList;
132: }
133: public function destroy($events)
134: {
135: foreach ($events as $event) {
136: $accessToken = $this->getAccessToken($event->user);
137: if ($accessToken) {
138: $this->client->setAccessToken($accessToken);
139: $service = new Google_Service_Calendar($this->client);
140: $service->events->delete($event->google_calendar_id, $event->google_event_id);
141: } else {
142: return redirect()->route('oauthCallback');
143: }
144: }
145: }
146: }
[app > Repositories > HolidayRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\DoctorHoliday;
4: use Illuminate\Http\RedirectResponse;
5: /**
6: * Class CityRepository
7: *
8: * @version July 31, 2021, 7:41 am UTC
9: */
10: class HolidayRepository extends BaseRepository
11: {
12: /**
13: * @var array
14: */
15: protected $fieldSearchable = [
16: 'name',
17: 'doctor_id',
18: 'date',
19: ];
20: /**
21: * Return searchable fields
22: */
23: public function getFieldsSearchable(): array
24: {
25: return $this->fieldSearchable;
26: }
27: /**
28: * Configure the Model
29: **/
30: public function model()
31: {
32: return DoctorHoliday::class;
33: }
34: public function store($input)
35: {
36: $doctor_holiday = DoctorHoliday::where('doctor_id',
$input['doctor_id'])->where('date',
37: $input['date'])->exists();
38: if (! $doctor_holiday) {
39: DoctorHoliday::create($input);
40: return true;
41: } else {
42: return false;
43: }
44: }
45: }
[app > Repositories > LiveConsultationRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App;
4: use App\Models\Doctor;
5: use App\Models\LiveConsultation;
6: use App\Models\Notification;
7: use App\Models\Patient;
8: use App\Models\UserZoomCredential;
9: use Carbon\Carbon;
10: use Exception;
11: use Illuminate\Contracts\Container\BindingResolutionException;
12: use Illuminate\Support\Collection;
13: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
14: /**
15: * Class LiveConsultationRepository
16: */
17: class LiveConsultationRepository extends BaseRepository
18: {
19: /**
20: * @var array
21: */
22: protected $fieldSearchable = [
23: 'doctor_id',
24: 'patient_id',
25: 'consultation_title',
26: 'consultation_date',
27: 'consultation_duration_minutes',
28: 'type',
29: 'type_number',
30: 'description',
31: ];
32: /**
33: * Return searchable fields
34: */
35: public function getFieldsSearchable(): array
36: {
37: return $this->fieldSearchable;
38: }
39: /**
40: * Configure the Model
41: **/
42: public function model()
43: {
44: return LiveConsultation::class;
45: }
46: public function getTypeNumber($input): Collection
47: {
48: }
49: /**
50: * @throws BindingResolutionException
51: */
52: public function store(array $input): bool
53: {
54: /** @var ZoomRepository $zoomRepo */
55: $zoomRepo = App::make(ZoomRepository::class);
56: try {
57: $input['created_by'] = getLogInUserId();
58: $startTime = $input['consultation_date'];
59: $input['consultation_date'] = Carbon::parse($startTime)->format('Y-m-d H:i:s');
60: $zoom = $zoomRepo->createZoomMeeting($input);
61: $input['password'] = $zoom['password'];
62: $input['meeting_id'] = $zoom['id'];
63: $input['meta'] = $zoom;
64: $input['status'] = LiveConsultation::STATUS_AWAITED;
65: $zoomModel = LiveConsultation::create($input);
66: return true;
67: } catch (Exception $e) {
68: throw new UnprocessableEntityHttpException($e->getMessage());
69: }
70: }
71: public function edit(array $input, LiveConsultation $liveConsultation): bool
72: {
73: /** @var ZoomRepository $zoomRepo */
74: $zoomRepo = App::make(ZoomRepository::class, ['createdBy' =>
75: $liveConsultation->created_by]);
76: try {
77: // $zoomRepo->update($liveConsultation->meeting_id, $input); needs to be updated
78: $zoomSessionUpdate = $zoomRepo->updateZoomMeeting($input, $liveConsultation);
79: // $zoom = $zoomRepo->zoomGet($liveConsultation->meeting_id, ['meeting_owner' =>
80: $liveConsultation->created_by]);
81: // $input['password'] = $zoom['data']['password'];
82: // $input['meta'] = $zoom['data'];
83: $input['created_by'] = getLogInUserId();
84: $input['created_by'] = $liveConsultation->created_by != getLogInUserId() ?
85: $liveConsultation->created_by : getLogInUserId();
86: $startTime = $input['consultation_date'];
87: $input['consultation_date'] = Carbon::parse($startTime)->format('Y-m-d H:i:s');
88: $zoomModel = $liveConsultation->update($input);
89: return true;
90: } catch (Exception $e) {
91: throw new UnprocessableEntityHttpException($e->getMessage());
92: }
93: }
94: /**
95: * @return mixed
96: */
97: public function createUserZoom(array $input)
98: {
99: try {
100: UserZoomCredential::updateOrCreate([
101: 'user_id' => getLogInUserId(),
102: ], [
103: 'user_id' => getLogInUserId(),
104: 'zoom_api_key' => $input['zoom_api_key'],
105: 'zoom_api_secret' => $input['zoom_api_secret'],
106: ]);
107: return true;
108: } catch (Exception $e) {
109: throw new UnprocessableEntityHttpException($e->getMessage());
110: }
111: }
112: public function createNotification(array $input = [])
113: {
114: try {
115: $patient = Patient::with('user')->where('id', $input['patient_id'])->first();
116: $doctor = Doctor::with('user')->where('id', $input['doctor_id'])->first();
117: $patientNotification = Notification::create([
118: 'title' => 'Your live consultation has been created by
'.$doctor->user->full_name.'.',
119: 'type' => Notification::LIVE_CONSULTATION,
120: 'user_id' => $patient->user->id,
121: ]);
122: $doctorNotification = Notification::create([
123: 'title' => $patient->user->full_name.' live consultation has been booked.',
124: 'type' => Notification::LIVE_CONSULTATION,
125: 'user_id' => $doctor->user->id,
126: ]);
127: } catch (Exception $e) {
128: throw new UnprocessableEntityHttpException($e->getMessage());
129: }
130: }
131: }
[app > Repositories > MedicineBillRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Category;
4: use App\Models\Doctor;
5: use App\Models\Medicine;
6: use App\Models\MedicineBill;
7: use App\Models\Patient;
8: use App\Models\SaleMedicine;
9: use App\Models\Setting;
10: use Exception;
11: use Illuminate\Support\Collection;
12: use Illuminate\Support\Facades\DB;
13: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
14: /**
15: * Class DoctorRepository
16: *
17: * @version February 13, 2020, 8:55 am UTC
18: */
19: class MedicineBillRepository extends BaseRepository
20: {
21: /**
22: * @var array
23: */
24: protected $fieldSearchable = [
25: 'to',
26: 'subject',
27: ];
28: /**
29: * Return searchable fields
30: */
31: public function getFieldsSearchable(): array
32: {
33: return $this->fieldSearchable;
34: }
35: /**
36: * Configure the Model
37: **/
38: public function model()
39: {
40: return MedicineBill::class;
41: }
42: public function update($medicineBill, $input): bool
43: {
44: try {
45: DB::beginTransaction();
46: $input['payment_status'] = isset($input['payment_status']) ? 1 :
47: $medicineBill->payment_status;
48: foreach ($input['medicine'] as $key => $inputSale) {
49: if (empty($input['medicine'][$key]) && $input['payment_status'] == false) {
50: throw new
51: UnprocessableEntityHttpException(__('messages.medicine_bills.medicine_not_selected'))
;
52: }
53: $saleMedincine = SaleMedicine::where('medicine_bill_id',
54: $input['medicine_bill'])->where('medicine_id', $input['medicine'][$key])->first();
55: if (isset($saleMedincine->sale_quantity) && $input['quantity'][$key]) {
56: if ($saleMedincine->sale_quantity < $input['quantity'][$key] &&
$input['payment_status']
57: == 1) {
58: throw new
UnprocessableEntityHttpException(__('messages.medicine_bills.update_quantity'));
59: }
60: }
61: }
62: $medicineBill->load('saleMedicine');
63: $previousMedicineIds = $medicineBill->saleMedicine->pluck('medicine_id');
64: $previousMedicineArray = [];
65: foreach ($previousMedicineIds as $previousMedicineId) {
66: $previousMedicineArray[] = $previousMedicineId;
67: }
68: $deleteIds = array_diff($previousMedicineArray, $input['medicine']);
69: if ($input['payment_status'] && $medicineBill->payment_status == true) {
70: foreach ($deleteIds as $key => $value) {
71: if (array_key_exists($key, $input['medicine'])) {
72: $updatedMedicine = Medicine::find($input['medicine'][$key]);
73: if ($updatedMedicine->available_quantity < $input['quantity'][$key]) {
74: $available = $updatedMedicine->available_quantity == null ? 0 :
75: $updatedMedicine->available_quantity;
76: throw new
77: UnprocessableEntityHttpException(__('messages.medicine_bills.available_quantity').'
78: '.$updatedMedicine->name.' '.__('messages.medicine_bills.is').' '.$available.'.');
79: }
80: }
81: }
82: foreach ($deleteIds as $deleteId) {
83: $deleteMedicine = Medicine::find($deleteId);
84: $saleMedicine = SaleMedicine::where('medicine_bill_id',
85: $medicineBill->id)->where('medicine_id', $deleteId)->first();
86: $deleteMedicine->update(['available_quantity' => $deleteMedicine->available_quantity
+
87: $saleMedicine->sale_quantity]);
88: }
89: foreach ($deleteIds as $key => $value) {
90: if (array_key_exists($key, $input['medicine'])) {
91: $updatedMedicine = Medicine::find($input['medicine'][$key]);
92: $updatedMedicine->update([
93: 'available_quantity' => $updatedMedicine->available_quantity -
$input['quantity'][$key],
94: ]);
95: }
96: }
97: }
98: $arr = collect($input['medicine']);
99: $duplicateIds = $arr->duplicates();
100: $prescriptionMedicineArray = [];
101: $inputdoseAndMedicine = [];
102: foreach ($medicineBill->saleMedicine as $saleMedicine) {
103: $prescriptionMedicineArray[$saleMedicine->medicine_id] =
$saleMedicine->sale_quantity;
104: }
105: foreach ($input['medicine'] as $key => $value) {
106: $inputdoseAndMedicine[$value] = $input['quantity'][$key];
107: }
108: foreach ($input['medicine'] as $key => $value) {
109: $result = array_intersect($prescriptionMedicineArray, $inputdoseAndMedicine);
110: $medicine = Medicine::find($input['medicine'][$key]);
111: if (! empty($duplicateIds)) {
112: foreach ($duplicateIds as $key => $value) {
113: $medicine = Medicine::find($duplicateIds[$key]);
114: throw new
115: UnprocessableEntityHttpException(__('messages.medicine_bills.duplicate_medicine'));
116: }
117: }
118: $saleMedicine = SaleMedicine::where('medicine_bill_id',
119: $medicineBill->id)->where('medicine_id', $medicine->id)->first();
120: $qty = $input['quantity'][$key];
121: if ($input['payment_status'] == true && $medicine->available_quantity < $qty &&
122: $medicineBill->payment_status == 0) {
123: $available = $medicine->available_quantity == null ? 0 :
$medicine->available_quantity;
124: throw new
125: UnprocessableEntityHttpException(__('messages.medicine_bills.available_quantity').'
126: '.$medicine->name.' '.__('messages.medicine_bills.is').' '.$available.'.');
127: }
128: if (! is_null($saleMedicine) && $input['payment_status'] == 1 &&
129: $medicineBill['payment_status'] == 1) {
130: $PreviousQty = $saleMedicine->sale_quantity == null ? 0 :
$saleMedicine->sale_quantity;
131: if ($PreviousQty > $qty) {
132: $medicine->update([
133: 'available_quantity' => $medicine->available_quantity + $PreviousQty - $qty,
134: ]);
135: }
136: }
137: if (! array_key_exists($input['medicine'][$key], $result) &&
$medicine->available_quantity
138: < $qty && $input['payment_status'] == false) {
139: $available = $medicine->available_quantity == null ? 0 :
$medicine->available_quantity;
140: throw new
141: UnprocessableEntityHttpException(__('messages.medicine_bills.available_quantity').'
142: '.$medicine->name.' '.__('messages.medicine_bills.is').' '.$available.'.');
143: }
144: }
145: $medicineBill->saleMedicine()->delete();
146: $beforeStatus = $medicineBill['payment_status'];
147: $medicineBill->Update([
148: 'patient_id' => $input['patient_id'],
149: 'net_amount' => $input['net_amount'],
150: 'discount' => $input['discount'],
151: 'payment_status' => $input['payment_status'],
152: 'payment_type' => $input['payment_type'],
153: 'total' => $input['total'],
154: 'tax_amount' => $input['tax'],
155: 'note' => $input['note'],
156: 'bill_date' => $input['bill_date'],
157: ]);
158: if ($input['category_id']) {
159: foreach ($input['category_id'] as $key => $value) {
160: $medicine = Medicine::find($input['medicine'][$key]);
161: SaleMedicine::create([
162: 'medicine_bill_id' => $medicineBill->id,
163: 'medicine_id' => $medicine->id,
164: 'sale_price' => $input['sale_price'][$key],
165: 'expiry_date' => $input['expiry_date'][$key],
166: 'sale_quantity' => $input['quantity'][$key],
167: 'tax' => $input['tax_medicine'][$key] == null ? 0 : $input['tax_medicine'][$key],
168: ]);
169: if ($input['payment_status'] == 1 && $beforeStatus == 0) {
170: $medicine->update([
171: 'available_quantity' => $medicine->available_quantity - $input['quantity'][$key],
172: ]);
173: }
174: }
175: }
176: DB::commit();
177: } catch (Exception $e) {
178: DB::rollBack();
179: throw new UnprocessableEntityHttpException($e->getMessage());
180: }
181: return true;
182: }
183: public function getPatients(): Collection
184: {
185: $patients = Patient::with('patientUser')
186: ->whereHas('patientUser', function (Builder $query) {
187: $query->where('status', 1);
188: })->get()->pluck('patientUser.full_name', 'id')->sort();
189: return $patients;
190: }
191: public function getMedicines()
192: {
193: $data['medicines'] = Medicine::all()->pluck('name', 'id')->toArray();
194: return $data;
195: }
196: public function getSettingList(): array
197: {
198: $settings = Setting::pluck('value', 'key')->toArray();
199: return $settings;
200: }
201: public function getDoctors(): Doctor
202: {
203: /** @var Doctor $doctors */
204: $doctors = Doctor::with('doctorUser')->get()->where('doctorUser.status', '=',
205: 1)->pluck('doctorUser.full_name',
206: 'id')->sort();
207: return $doctors;
208: }
209: public function getMedicinesCategoriesData(): Collection
210: {
211: return Category::where('is_active', '=', 1)->pluck('name', 'id');
212: }
213: public function getMedicineCategoriesList(): array
214: {
215: $result = Category::where('is_active', '=', 1)->pluck('name', 'id')->toArray();
216: $medicineCategories = [];
217: foreach ($result as $key => $item) {
218: $medicineCategories[] = [
219: 'key' => $key,
220: 'value' => $item,
221: ];
222: }
223: return $medicineCategories;
224: }
225: }
[app > Repositories > MedicineRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Brand;
4: use App\Models\Category;
5: use App\Models\Medicine;
6: use App\Models\Prescription;
7: /**
8: * Class MedicineRepository
9: *
10: * @version February 12, 2020, 11:00 am UTC
11: */
12: class MedicineRepository extends BaseRepository
13: {
14: /**
15: * @var array
16: */
17: protected $fieldSearchable = [
18: 'name',
19: 'selling_price',
20: 'buying_price',
21: 'generic_name',
22: 'batch_no',
23: 'effect',
24: 'betch_no',
25: 'qty',
26: 'mfg_date',
27: ];
28: /**
29: * Return searchable fields
30: */
31: public function getFieldsSearchable(): array
32: {
33: return $this->fieldSearchable;
34: }
35: /**
36: * Configure the Model
37: **/
38: public function model()
39: {
40: return Medicine::class;
41: }
42: public function getSyncList(): array
43: {
44: $data['categories'] = Category::all()->where('is_active', '=', 1)->pluck('name',
45: 'id')->toArray();
46: $data['brands'] = Brand::all()->pluck('name', 'id')->toArray();
47: return $data;
48: }
49: public function getMedicineList()
50: {
51: $result = Medicine::all()->pluck('name', 'id')->toArray();
52: $medicines = [];
53: foreach ($result as $key => $item) {
54: $medicines[] = [
55: 'key' => $key,
56: 'value' => $item,
57: ];
58: }
59: return $medicines;
60: }
61: public function getMealList()
62: {
63: $result = Prescription::MEAL_ARR;
64: $meal = [];
65: foreach ($result as $key => $item) {
66: $meal[] = [
67: 'key' => $key,
68: 'value' => $item,
69: ];
70: }
71: return $meal;
72: }
73: public function getDoseInterValList()
74: {
75: $result = Prescription::DOSE_INTERVAL;
76: $doseInterVal = [];
77: foreach ($result as $key => $item) {
78: $doseInterVal[] = [
79: 'key' => $key,
80: 'value' => $item,
81: ];
82: }
83: return $doseInterVal;
84: }
85: public function getDoseDurationList()
86: {
87: $result = Prescription::DOSE_DURATION;
88: $doseDuration = [];
89: foreach ($result as $key => $item) {
90: $doseDuration[] = [
91: 'key' => $key,
92: 'value' => $item,
93: ];
94: }
95: return $doseDuration;
96: }
97: }
[app > Repositories > PatientRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Country;
4: use App\Models\Patient;
5: use App\Models\User;
6: use Illuminate\Support\Arr;
7: use Illuminate\Support\Facades\DB;
8: use Illuminate\Support\Facades\Hash;
9: use Illuminate\Support\Str;
10: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
11: use Illuminate\Support\Facades\Session;
12: use App\Models\Setting;
13: /**
14: * Class PatientRepository
15: *
16: * @version July 29, 2021, 11:37 am UTC
17: */
18: class PatientRepository extends BaseRepository
19: {
20: /**
21: * @var array
22: */
23: protected $fieldSearchable = [
24: ];
25: /**
26: * Return searchable fields
27: */
28: public function getFieldsSearchable(): array
29: {
30: return $this->fieldSearchable;
31: }
32: /**
33: * Configure the Model
34: **/
35: public function model()
36: {
37: return Patient::class;
38: }
39: public function getData(): array
40: {
41: $data['patientUniqueId'] = mb_strtoupper(Patient::generatePatientUniqueId());
42: $data['countries'] = Country::toBase()->pluck('name', 'id');
43: $data['bloodGroupList'] = Patient::BLOOD_GROUP_ARRAY;
44: return $data;
45: }
46: public function store($input): bool
47: {
48: try {
49: DB::beginTransaction();
50: $addressInputArray = Arr::only($input,
51: ['address1', 'address2', 'city_id', 'state_id', 'country_id', 'postal_code']);
52: $input['patient_unique_id'] = Str::upper($input['patient_unique_id']);
53: $input['email'] = setEmailLowerCase($input['email']);
54: $patientArray = Arr::only($input, ['patient_unique_id']);
55: $input['type'] = User::PATIENT;
56: $input['language'] = Setting::where('key','language')->get()->toArray()[0]['value'];
57: $input['password'] = Hash::make($input['password']);
58: $user = User::create($input);
59: $patient = $user->patient()->create($patientArray);
60: $address = $patient->address()->create($addressInputArray);
61: $user->assignRole('patient');
62: if (isset($input['profile']) && ! empty($input['profile'])) {
63: $patient->addMedia($input['profile'])->toMediaCollection(Patient::PROFILE,
64: config('app.media_disc'));
65: }
66: $user->sendEmailVerificationNotification();
67: DB::commit();
68: return true;
69: } catch (\Exception $e) {
70: throw new UnprocessableEntityHttpException($e->getMessage());
71: }
72: }
73: public function update($input, $patient): bool
74: {
75: try {
76: DB::beginTransaction();
77: $addressInputArray = Arr::only($input,
78: ['address1', 'address2', 'city_id', 'state_id', 'country_id', 'postal_code']);
79: $input['type'] = User::PATIENT;
80: $input['email'] = setEmailLowerCase($input['email']);
81: /** @var Patient $patient */
82: $patient->user()->update(Arr::except($input, [
83: 'address1', 'address2', 'city_id', 'state_id', 'country_id', 'postal_code',
84: 'patient_unique_id',
85: 'avatar_remove',
86: 'profile', 'is_edit', 'edit_patient_country_id', 'edit_patient_state_id',
87: 'edit_patient_city_id',
88: 'backgroundImg',
89: ]));
90: if(isset($patient->address)){
91: $patient->address()->update($addressInputArray);
92: }else{
93: $patient->address()->create($addressInputArray);
94: }
95: if (isset($input['profile']) && ! empty($input['profile'])) {
96: $patient->clearMediaCollection(Patient::PROFILE);
97: $patient->media()->delete();
98: $patient->addMedia($input['profile'])->toMediaCollection(Patient::PROFILE,
99: config('app.media_disc'));
100: }
101: DB::commit();
102: return true;
103: } catch (\Exception $e) {
104: throw new UnprocessableEntityHttpException($e->getMessage());
105: }
106: }
107: /**
108: * @return mixed
109: */
110: public function getPatientData($input)
111: {
112: $patient = Patient::with(['user.address', 'appointments',
113: 'address'])->findOrFail($input['id']);
114: return $patient;
115: }
116: }
[app > Repositories > PatientVisitRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Visit;
4: use Illuminate\Database\Eloquent\Builder;
5: use Illuminate\Database\Eloquent\Collection;
6: use Illuminate\Database\Eloquent\Model;
7: /**
8: * Class EncounterRepository
9: *
10: * @version September 3, 2021, 7:09 am UTC
11: */
12: class PatientVisitRepository extends BaseRepository
13: {
14: /**
15: * @var array
16: */
17: protected $fieldSearchable = [
18: 'visit_date',
19: 'doctor',
20: ];
21: /**
22: * Return searchable fields
23: */
24: public function getFieldsSearchable(): array
25: {
26: return $this->fieldSearchable;
27: }
28: /**
29: * Configure the Model
30: **/
31: public function model()
32: {
33: return Visit::class;
34: }
35: /**
36: * @return Builder|Builder[]|Collection|Model|null
37: */
38: public function getShowData($id)
39: {
40: return Visit::with([
41: 'visitDoctor.user', 'problems', 'observations', 'notes', 'prescriptions',
42: ])->findOrFail($id);
43: }
44: }
[app > Repositories > PrescriptionRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Doctor;
4: use App\Models\Medicine;
5: use App\Models\MedicineBill;
6: use App\Models\Notification;
7: use App\Models\Patient;
8: use App\Models\Prescription;
9: use App\Models\PrescriptionMedicineModal;
10: use App\Models\SaleMedicine;
11: use App\Models\Setting;
12: use Auth;
13: use Carbon\Carbon;
14: use Exception;
15: use Illuminate\Database\Eloquent\Builder;
16: use Illuminate\Database\Eloquent\Collection;
17: use Illuminate\Database\Eloquent\Model;
18: use Illuminate\Support\Facades\DB;
19: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
20: /**
21: * Class PrescriptionRepository
22: *
23: * @version March 31, 2020, 12:22 pm UTC
24: */
25: class PrescriptionRepository extends BaseRepository
26: {
27: /**
28: * @var array
29: */
30: protected $fieldSearchable = [
31: 'patient_id',
32: 'food_allergies',
33: 'tendency_bleed',
34: 'heart_disease',
35: 'high_blood_pressure',
36: 'diabetic',
37: 'surgery',
38: 'accident',
39: 'others',
40: 'medical_history',
41: 'current_medication',
42: 'female_pregnancy',
43: 'breast_feeding',
44: 'health_insurance',
45: 'low_income',
46: 'reference',
47: 'status',
48: ];
49: /**
50: * Return searchable fields
51: */
52: public function getFieldsSearchable(): array
53: {
54: return $this->fieldSearchable;
55: }
56: /**
57: * Configure the Model
58: **/
59: public function model()
60: {
61: return Prescription::class;
62: }
63: public function getPatients(): \Illuminate\Support\Collection
64: {
65: $user = Auth::user();
66: if ($user->hasRole('Doctor')) {
67: $patients = getPatientsList($user->owner_id);
68: } else {
69: $patients = Patient::with('user')
70: ->whereHas('user', function (Builder $query) {
71: $query->where('status', 1);
72: })->get()->pluck('user.full_name', 'id')->sort();
73: }
74: return $patients;
75: }
76: /**
77: * @param array $prescription
78: * @return bool|Builder|Builder[]|Collection|Model
79: */
80: // public function update($prescription, $input)
81: // {
82: // try {
83: // /** @var Prescription $prescription */
84: // $prescription->update($input);
85: //
86: // return true;
87: // } catch (Exception $e) {
88: // throw new UnprocessableEntityHttpException($e->getMessage());
89: // }
90: // }
91: public function createNotification(array $input)
92: {
93: try {
94: $patient = Patient::with('user')->where('id', $input['patient_id'])->first();
95: addNotification([
96: Notification::NOTIFICATION_TYPE['Prescription'],
97: $patient->user_id,
98: Notification::NOTIFICATION_FOR[Notification::PATIENT],
99: $patient->user->full_name.' your prescription has been created.',
100: ]);
101: } catch (Exception $e) {
102: throw new UnprocessableEntityHttpException($e->getMessage());
103: }
104: }
105: public function getMedicines(): array
106: {
107: $data['medicines'] = Medicine::where('available_quantity', '>', 0)->pluck('name',
108: 'id')->toArray();
109: return $data;
110: }
111: public function getMedicinesQuantity() {
112: $data = Medicine::where('available_quantity', '>', 0)->pluck('quantity')->toArray();
113: return $data;
114: }
115: public function createPrescription(array $input, Model $prescription)
116: {
117: try {
118: DB::beginTransaction();
119: $amount = 0;
120: $qty = 0;
121: if (isset($input['medicine'])) {
122: $medicineBill = MedicineBill::create([
123: 'bill_number' => 'BIL'.generateUniqueBillNumber(),
124: 'patient_id' => $input['patient_id'],
125: 'doctor_id' => $input['doctor_id'],
126: 'model_type' => \App\Models\Prescription::class,
127: 'model_id' => $prescription->id,
128: 'bill_date' => Carbon::now(),
129: 'payment_status' => MedicineBill::UNPAID,
130: ]);
131: foreach ($input['medicine'] as $key => $value) {
132: $PrescriptionItem = [
133: 'prescription_id' => $prescription->id,
134: 'medicine' => $input['medicine'][$key],
135: 'dosage' => $input['dosage'][$key],
136: 'day' => $input['day'][$key],
137: 'time' => $input['time'][$key],
138: 'dose_interval' => $input['dose_interval'][$key],
139: 'comment' => $input['comment'][$key],
140: ];
141: $prescriptionMedcine = PrescriptionMedicineModal::create($PrescriptionItem);
142: $medicine = Medicine::find($input['medicine'][$key]);
143: $amount += $input['day'][$key] * $input['dose_interval'][$key] *
$medicine->selling_price;
144: $qty = $input['day'][$key] * $input['dose_interval'][$key];
145: $saleMedicineArray = [
146: 'medicine_bill_id' => $medicineBill->id,
147: 'medicine_id' => $medicine->id,
148: 'sale_quantity' => $qty,
149: 'sale_price' => $medicine->selling_price,
150: 'tax' => 0,
151: ];
152: SaleMedicine::create($saleMedicineArray);
153: }
154: $medicineBill->update([
155: 'net_amount' => $amount,
156: 'total' => $amount,
157: ]);
158: }
159: DB::commit();
160: } catch (Exception $e) {
161: DB::rollBack();
162: throw new UnprocessableEntityHttpException($e->getMessage());
163: }
164: }
165: /**
166: * @return mixed
167: */
168: public function prescriptionUpdate($prescription, $input)
169: {
170: try {
171: DB::beginTransaction();
172: $prescriptionMedicineArr = \Arr::only($input, $this->model->getFillable());
173: $prescription->update($prescriptionMedicineArr);
174: $medicineBill =
175: MedicineBill::with('saleMedicine')->whereModelType(\App\Models\Prescription::class)-
>whereModelId($prescription->id)->first();
176: $prescription->getMedicine()->delete();
177: $medicineBill->saleMedicine()->delete();
178: $amount = 0;
179: $qty = 0;
180: if (! empty($input['medicine'])) {
181: foreach ($input['medicine'] as $key => $value) {
182: $PrescriptionItem = [
183: 'prescription_id' => $prescription->id,
184: 'medicine' => $input['medicine'][$key],
185: 'dosage' => $input['dosage'][$key],
186: 'day' => $input['day'][$key],
187: 'time' => $input['time'][$key],
188: 'dose_interval' => $input['dose_interval'][$key],
189: 'comment' => $input['comment'][$key],
190: ];
191: $prescriptionMedcine = PrescriptionMedicineModal::create($PrescriptionItem);
192: $medicine = Medicine::find($input['medicine'][$key]);
193: $amount += $input['day'][$key] * $input['dose_interval'][$key] *
$medicine->selling_price;
194: $qty = $input['day'][$key] * $input['dose_interval'][$key];
195: $saleMedicineArray = [
196: 'medicine_bill_id' => $medicineBill->id,
197: 'medicine_id' => $medicine->id,
198: 'sale_quantity' => $qty,
199: 'sale_price' => $medicine->selling_price,
200: 'tax' => 0,
201: ];
202: SaleMedicine::create($saleMedicineArray);
203: }
204: $medicineBill->update([
205: 'net_amount' => $amount,
206: // 'discount'=>$input['discount'],
207: // 'tax_amount'=>$input['tax'],
208: ]);
209: }
210: DB::commit();
211: } catch (Exception $e) {
212: DB::rollBack();
213: throw new UnprocessableEntityHttpException($e->getMessage());
214: }
215: return $prescription;
216: }
217: public function getData($id): array
218: {
219: $data['prescription'] = Prescription::with('patient', 'doctor',
'getMedicine.medicines')
220: ->findOrFail($id);
221: return $data;
222: }
223: public function getMedicineData($id): array
224: {
225: $data = $this->getData($id)['prescription'];
226: $medicines = [];
227: foreach ($data->getMedicine as $medicine) {
228: $data['medicine'] = Medicine::where('id', $medicine->medicine)->get();
229: array_push($medicines, $data['medicine']);
230: }
231: return $medicines;
232: }
233: public function getSettingList(): array
234: {
235: $settings = Setting::pluck('value', 'key')->toArray();
236: return $settings;
237: }
238: public function getDoctors()
239: {
240: /** @var Doctor $doctors */
241: $doctors = Doctor::with('doctorUser')->get()->where('doctorUser.status', '=',
242: 1)->pluck('doctorUser.full_name', 'id')->sort();
243: return $doctors;
244: }
245: }
[app > Repositories > PurchaseMedicineRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Accountant;
4: use App\Models\Address;
5: use App\Models\Category;
6: use App\Models\Medicine;
7: use App\Models\PurchasedMedicine;
8: use App\Models\PurchaseMedicine;
9: use App\Models\User;
10: use Arr;
11: use Exception;
12: use Illuminate\Database\Eloquent\Builder;
13: use Illuminate\Database\Eloquent\Collection;
14: use Illuminate\Database\Eloquent\Model;
15: use Illuminate\Support\Facades\DB;
16: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
17: /**
18: * Class AccountantRepository
19: *
20: * @version February 17, 2020, 5:34 am UTC
21: */
22: class PurchaseMedicineRepository extends BaseRepository
23: {
24: /**
25: * @var array
26: */
27: protected $fieldSearchable = [
28: 'purchase_numeber',
29: 'purchase_date',
30: 'bill_number',
31: 'supplier_name',
32: ];
33: /**
34: * Return searchable fields
35: */
36: public function getFieldsSearchable(): array
37: {
38: return $this->fieldSearchable;
39: }
40: /**
41: * Configure the Model
42: **/
43: public function model()
44: {
45: return PurchaseMedicine::class;
46: }
47: public function getMedicine()
48: {
49: $data['medicines'] = Medicine::all()->pluck('name', 'id')->toArray();
50: return $data;
51: }
52: public function getMedicineList()
53: {
54: $result = Medicine::all()->pluck('name', 'id')->toArray();
55: $medicines = [];
56: foreach ($result as $key => $item) {
57: $medicines[] = [
58: 'key' => $key,
59: 'value' => $item,
60: ];
61: }
62: return $medicines;
63: }
64: public function getCategoryList()
65: {
66: $result = Category::all()->pluck('name', 'id')->toArray();
67: $category = [];
68: foreach ($result as $key => $item) {
69: $medicines[] = [
70: 'key' => $key,
71: 'value' => $item,
72: ];
73: }
74: return $category;
75: }
76: public function getCategory()
77: {
78: $data['categories'] = Category::all()->pluck('name', 'id')->toArray();
79: return $data;
80: }
81: /**
82: * @param bool $mail
83: */
84: public function store(array $input): bool
85: {
86: try {
87: DB::beginTransaction();
88: $purchaseMedicineArray = Arr::only($input, $this->model->getFillable());
89: $purchaseMedicine = PurchaseMedicine::create($purchaseMedicineArray);
90: foreach ($input['medicine'] as $key => $value) {
91: $tax = $input['tax_medicine'][$key] == null ? $input['tax_medicine'][$key] : 0;
92: $purchasedMedicineArray = [
93: 'purchase_medicines_id' => $purchaseMedicine->id,
94: 'medicine_id' => $input['medicine'][$key],
95: 'lot_no' => $input['lot_no'][$key],
96: 'tax' => $tax,
97: 'expiry_date' => $input['expiry_date'][$key],
98: 'quantity' => $input['quantity'][$key],
99: 'amount' => $input['amount'][$key],
100: 'tenant_id',
101: ];
102: PurchasedMedicine::create($purchasedMedicineArray);
103: $medicine = Medicine::find($input['medicine'][$key]);
104: $medicineQtyArray = [
105: 'quantity' => $input['quantity'][$key] + $medicine->quantity,
106: 'available_quantity' => $input['quantity'][$key] + $medicine->available_quantity,
107: ];
108: $medicine->update($medicineQtyArray);
109: }
110: DB::commit();
111: return true;
112: } catch (Exception $e) {
113: DB::rollBack();
114: throw new UnprocessableEntityHttpException($e->getMessage());
115: }
116: }
117: /**
118: * @return bool|Builder|Builder[]|Collection|Model
119: */
120: public function update($accountant, $input)
121: {
122: try {
123: unset($input['password']);
124: /** @var User $user */
125: $user = User::find($accountant->user->id);
126: if (isset($input['image']) && ! empty($input['image'])) {
127: $mediaId = updateProfileImage($user, $input['image']);
128: }
129: if ($input['avatar_remove'] == 1 && isset($input['avatar_remove']) && !
130: empty($input['avatar_remove'])) {
131: removeFile($user, User::COLLECTION_PROFILE_PICTURES);
132: }
133: /** @var Accountant $accountant */
134: $input['phone'] = preparePhoneNumber($input, 'phone');
135: $input['dob'] = (! empty($input['dob'])) ? $input['dob'] : null;
136: $accountant->user->update($input);
137: $accountant->update($input);
138: if (! empty($accountant->address)) {
139: if (empty($address = Address::prepareAddressArray($input))) {
140: $accountant->address->delete();
141: }
142: $accountant->address->update($input);
143: } else {
144: if (! empty($address = Address::prepareAddressArray($input)) &&
145: empty($accountant->address)) {
146: $ownerId = $accountant->id;
147: $ownerType = Accountant::class;
148: Address::create(array_merge($address, ['owner_id' => $ownerId, 'owner_type' =>
149: $ownerType]));
150: }
151: }
152: return true;
153: } catch (Exception $e) {
154: throw new UnprocessableEntityHttpException($e->getMessage());
155: }
156: }
157: }
[app > Repositories > RoleRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Permission;
4: use App\Models\Role;
5: /**
6: * Class RoleRepository
7: *
8: * @version August 5, 2021, 10:43 am UTC
9: */
10: class RoleRepository extends BaseRepository
11: {
12: /**
13: * @var array
14: */
15: protected $fieldSearchable = [
16: 'name',
17: ];
18: /**
19: * Return searchable fields
20: */
21: public function getFieldsSearchable(): array
22: {
23: return $this->fieldSearchable;
24: }
25: /**
26: * Configure the Model
27: **/
28: public function model()
29: {
30: return Role::class;
31: }
32: /**
33: * @return mixed
34: */
35: public function getPermissions()
36: {
37: $permissions['permissions'] = Permission::toBase()->where('name', '!=',
38: 'manage_admin_dashboard')->get();
39: $permissions['count'] = Permission::count();
40: return $permissions;
41: }
42: public function store($input): Role
43: {
44: $displayName = strtolower($input['display_name']);
45: $input['name'] = str_replace(' ', '_', $displayName);
46: /** @var Role $role */
47: $role = Role::create($input);
48: if (isset($input['permission_id']) && ! empty($input['permission_id'])) {
49: $role->permissions()->sync($input['permission_id']);
50: }
51: return $role;
52: }
53: public function update($input, $id): Role
54: {
55: $displayName = strtolower($input['display_name']);
56: $str = str_replace(' ', '_', $displayName);
57: $role = Role::findById($id);
58: /** @var Role $role */
59: $role->update([
60: 'name' => $str,
61: 'display_name' => $input['display_name'],
62: ]);
63: if (isset($input['permission_id']) && ! empty($input['permission_id'])) {
64: $role->permissions()->sync($input['permission_id']);
65: }
66: return $role;
67: }
68: }
[app > Repositories > ServiceCategoryRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\ServiceCategory;
4: /**
5: * Class ServiceCategoryRepository
6: *
7: * @version August 2, 2021, 7:11 am UTC
8: */
9: class ServiceCategoryRepository extends BaseRepository
10: {
11: /**
12: * @var array
13: */
14: protected $fieldSearchable = [
15: 'name',
16: ];
17: /**
18: * Return searchable fields
19: */
20: public function getFieldsSearchable(): array
21: {
22: return $this->fieldSearchable;
23: }
24: /**
25: * Configure the Model
26: **/
27: public function model()
28: {
29: return ServiceCategory::class;
30: }
31: }
[app > Repositories > ServicesRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Http\Controllers\AppBaseController;
4: use App\Models\Doctor;
5: use App\Models\Service;
6: use App\Models\ServiceCategory;
7: use DB;
8: use Exception;
9: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
10: /**
11: * Class ServicesRepository
12: *
13: * @version August 2, 2021, 12:09 pm UTC
14: */
15: class ServicesRepository extends AppBaseController
16: {
17: /**
18: * @var array
19: */
20: protected $fieldSearchable = [
21: 'category_id',
22: 'name',
23: 'charges',
24: 'doctors',
25: 'status',
26: ];
27: /**
28: * Return searchable fields
29: */
30: public function getFieldsSearchable(): array
31: {
32: return $this->fieldSearchable;
33: }
34: /**
35: * Configure the Model
36: **/
37: public function model()
38: {
39: return Service::class;
40: }
41: public function store(array $input): bool
42: {
43: try {
44: DB::beginTransaction();
45: $input['charges'] = str_replace(',', '', $input['charges']);
46: $input['status'] = (isset($input['status'])) ? 1 : 0;
47: $services = Service::create($input);
48: if (isset($input['doctors']) && ! empty($input['doctors'])) {
49: $services->serviceDoctors()->sync($input['doctors']);
50: }
51: if (isset($input['icon']) && ! empty('icon')) {
52: $services->addMedia($input['icon'])->toMediaCollection(Service::ICON,
53: config('app.media_disc'));
54: }
55: DB::commit();
56: return true;
57: } catch (Exception $e) {
58: DB::rollBack();
59: throw new UnprocessableEntityHttpException($e->getMessage());
60: }
61: }
62: public function update($input, $service): bool
63: {
64: try {
65: DB::beginTransaction();
66: $input['charges'] = str_replace(',', '', $input['charges']);
67: $input['status'] = (isset($input['status'])) ? 1 : 0;
68: $service->update($input);
69: $service->serviceDoctors()->sync($input['doctors']);
70: if (isset($input['icon']) && ! empty('icon')) {
71: $service->clearMediaCollection(Service::ICON);
72: $service->media()->delete();
73: $service->addMedia($input['icon'])->toMediaCollection(Service::ICON,
74: config('app.media_disc'));
75: }
76: DB::commit();
77: return true;
78: } catch (Exception $e) {
79: DB::rollBack();
80: throw new UnprocessableEntityHttpException($e->getMessage());
81: }
82: }
83: public function prepareData(): array
84: {
85: $data['serviceCategories'] = ServiceCategory::orderBy('name', 'ASC')->pluck('name',
'id');
86: $data['doctors'] = Doctor::with('user')->get()->where('user.status',
87: true)->pluck('user.full_name', 'id');
88: return $data;
89: }
90: }
[app > Repositories > SettingRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Setting;
4: use Illuminate\Support\Arr;
5: use Illuminate\Support\Facades\Cache;
6: use Spatie\MediaLibrary\MediaCollections\Exceptions\FileDoesNotExist;
7: use Spatie\MediaLibrary\MediaCollections\Exceptions\FileIsTooBig;
8: /**
9: * Class UserRepository
10: */
11: class SettingRepository extends BaseRepository
12: {
13: public $fieldSearchable = [
14: 'clinic_name',
15: ];
16: /**
17: * {@inheritDoc}
18: */
19: public function getFieldsSearchable()
20: {
21: return $this->fieldSearchable;
22: }
23: /**
24: * {@inheritDoc}
25: */
26: public function model()
27: {
28: return Setting::class;
29: }
30: /**
31: * @throws FileIsTooBig
32: * @throws FileDoesNotExist
33: */
34: public function update($input, $userId): void
35: {
36: $inputArr = Arr::except($input, ['_token']);
37: if ($inputArr['sectionName'] == 'general') {
38: $inputArr['clinic_name'] = (empty($inputArr['clinic_name'])) ? '' :
39: $inputArr['clinic_name'];
40: $inputArr['contact_no'] = (empty($inputArr['contact_no'])) ? '' :
$inputArr['contact_no'];
41: $inputArr['email'] = (empty($inputArr['email'])) ? '' : $inputArr['email'];
42: $inputArr['specialities'] = (empty($inputArr['specialities'])) ? '1' :
43: json_encode($inputArr['specialities']);
44: $inputArr['currency'] = (empty($inputArr['currency'])) ? '1' : $inputArr['currency'];
45: $inputArr['prefix'] = (empty($inputArr['prefix'])) ? '' : $inputArr['prefix'];
46: $inputArr['region_code'] = (empty($inputArr['region_code'])) ? '' :
47: $inputArr['region_code'];
48: $inputArr['email_verified'] = (empty($inputArr['email_verified'])) ? '0' :
49: $inputArr['email_verified'];
50: $inputArr['default_country_code'] = (empty($inputArr['default_country_code'])) ? '' :
51: $inputArr['default_country_code'];
52: }
53: if ($inputArr['sectionName'] == 'contact_information') {
54: $inputArr['address_one'] = (empty($inputArr['address_one'])) ? '' :
55: $inputArr['address_one'];
56: $inputArr['address_two'] = (empty($inputArr['address_two'])) ? '' :
57: $inputArr['address_two'];
58: $inputArr['country'] = (empty($inputArr['country'])) ? '1' : $inputArr['country'];
59: $inputArr['state'] = (empty($inputArr['state'])) ? '1' : $inputArr['state'];
60: $inputArr['city'] = (empty($inputArr['city'])) ? '1' : $inputArr['city'];
61: $inputArr['postal_code'] = (empty($inputArr['postal_code'])) ? '' :
62: $inputArr['postal_code'];
63: }
64: foreach ($inputArr as $key => $value) {
65: /** @var Setting $setting */
66: $setting = Setting::where('key', $key)->first();
67: if (! $setting) {
68: continue;
69: }
70: $setting->update(['value' => $value]);
71: if (in_array($key, ['logo']) && ! empty($value)) {
72: $setting->clearMediaCollection(Setting::LOGO);
73: $media = $setting->addMedia($value)->toMediaCollection(Setting::LOGO,
74: config('app.media_disc'));
75: $setting->update(['value' => $media->getUrl()]);
76: }
77: if (in_array($key, ['favicon']) && ! empty($value)) {
78: $setting->clearMediaCollection(Setting::FAVICON);
79: $media = $setting->addMedia($value)->toMediaCollection(Setting::FAVICON,
80: config('app.media_disc'));
81: $setting->update(['value' => $media->getUrl()]);
82: }
83: }
84: Cache::flush('settings');
85: Cache::put('settings', Setting::all()->keyBy('key'));
86: }
87: }
[app > Repositories > SliderRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Slider;
4: use Exception;
5: use Illuminate\Support\Facades\DB;
6: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
7: /**
8: * Class StaffRepository
9: *
10: * @version September 21, 2021, 11:40 am UTC
11: */
12: class SliderRepository extends BaseRepository
13: {
14: /**
15: * @var array
16: */
17: protected $fieldSearchable = [
18: 'title',
19: 'short_description',
20: ];
21: /**
22: * Return searchable fields
23: */
24: public function getFieldsSearchable(): array
25: {
26: return $this->fieldSearchable;
27: }
28: /**
29: * Configure the Model
30: **/
31: public function model()
32: {
33: return Slider::class;
34: }
35: public function store($input): bool
36: {
37: try {
38: DB::beginTransaction();
39: $slider = slider::create($input);
40: if (isset($input['image']) && ! empty($input['image'])) {
41: $slider->addMedia($input['image'])->toMediaCollection(Slider::SLIDER_IMAGE,
42: config('app.media_disc'));
43: }
44: DB::commit();
45: return true;
46: } catch (Exception $e) {
47: DB::rollBack();
48: throw new UnprocessableEntityHttpException($e->getMessage());
49: }
50: }
51: public function update($input, $id): bool
52: {
53: try {
54: DB::beginTransaction();
55: $slider = slider::findOrFail($id);
56: $slider->update($input);
57: if (isset($input['image']) && ! empty($input['image'])) {
58: $slider->clearMediaCollection(Slider::SLIDER_IMAGE);
59: $slider->media()->delete();
60: $slider->addMedia($input['image'])->toMediaCollection(Slider::SLIDER_IMAGE,
61: config('app.media_disc'));
62: }
63: DB::commit();
64: return true;
65: } catch (Exception $e) {
66: DB::rollBack();
67: throw new UnprocessableEntityHttpException($e->getMessage());
68: }
69: }
70: }
[app > Repositories > SmartPatientCardsRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\SmartPatientCards;
4: use Exception;
5: use Illuminate\Support\Facades\DB;
6: use Illuminate\Support\Facades\Hash;
7: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
8: use App\Models\User;
9: /**
10: * Class StaffRepository
11: *
12: * @version August 6, 2021, 10:17 am UTC
13: */
14: class SmartPatientCardsRepository extends BaseRepository
15: {
16: /**
17: * @var array
18: */
19: protected $fieldSearchable = [
20: 'template_name',
21: 'address',
22: 'header_color',
23: 'show_email',
24: 'show_phone',
25: 'show_dob',
26: 'show_blood_group',
27: 'show_address',
28: 'show_patient_unique_id',
29: ];
30: public function getFieldsSearchable(): array
31: {
32: return $this->fieldSearchable;
33: }
34: public function model()
35: {
36: return SmartPatientCards::class;
37: }
38: public function store($input): bool
39: {
40: try {
41: DB::beginTransaction();
42: $input['show_email'] = isset($input['show_email']) ? 1 : 0;
43: $input['show_phone'] = isset($input['show_phone']) ? 1 : 0;
44: $input['show_dob'] = isset($input['show_dob']) ? 1 : 0;
45: $input['show_blood_group'] = isset($input['show_blood_group']) ? 1 : 0;
46: $input['show_address'] = isset($input['show_address']) ? 1 : 0;
47: $input['show_patient_unique_id'] = isset($input['show_patient_unique_id']) ? 1 : 0;
48: $smartcard = SmartPatientCards::create($input);
49: DB::commit();
50: return true;
51: } catch (Exception $e) {
52: DB::rollBack();
53: throw new UnprocessableEntityHttpException($e->getMessage());
54: }
55: }
56: public function update($input, $id)
57: {
58: try {
59: DB::beginTransaction();
60: $smartcard = SmartPatientCards::find($id);
61: $input['show_email'] = isset($input['show_email']) ? 1 : 0;
62: $input['show_phone'] = isset($input['show_phone']) ? 1 : 0;
63: $input['show_dob'] = isset($input['show_dob']) ? 1 : 0;
64: $input['show_blood_group'] = isset($input['show_blood_group']) ? 1 : 0;
65: $input['show_address'] = isset($input['show_address']) ? 1 : 0;
66: $input['show_patient_unique_id'] = isset($input['show_patient_unique_id']) ? 1 : 0;
67: $smartcard->update($input);
68: DB::commit();
69: return true;
70: } catch (Exception $e) {
71: DB::rollBack();
72: throw new UnprocessableEntityHttpException($e->getMessage());
73: }
74: }
75: }
[app > Repositories > SpecializationRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Specialization;
4: /**
5: * Class SpecializationRepository
6: *
7: * @version August 2, 2021, 10:19 am UTC
8: */
9: class SpecializationRepository extends BaseRepository
10: {
11: /**
12: * @var array
13: */
14: protected $fieldSearchable = [
15: 'name',
16: ];
17: /**
18: * Return searchable fields
19: */
20: public function getFieldsSearchable(): array
21: {
22: return $this->fieldSearchable;
23: }
24: /**
25: * Configure the Model
26: **/
27: public function model()
28: {
29: return Specialization::class;
30: }
31: }
[app > Repositories > StaffRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Role;
4: use App\Models\Staff;
5: use App\Models\User;
6: use Exception;
7: use Illuminate\Support\Facades\DB;
8: use Illuminate\Support\Facades\Hash;
9: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
10: /**
11: * Class StaffRepository
12: *
13: * @version August 6, 2021, 10:17 am UTC
14: */
15: class StaffRepository extends BaseRepository
16: {
17: /**
18: * @var array
19: */
20: protected $fieldSearchable = [
21: 'first_name',
22: 'last_name',
23: 'email',
24: 'phone_number',
25: 'password',
26: 'gender',
27: 'role',
28: ];
29: /**
30: * Return searchable fields
31: */
32: public function getFieldsSearchable(): array
33: {
34: return $this->fieldSearchable;
35: }
36: /**
37: * Configure the Model
38: **/
39: public function model()
40: {
41: return Staff::class;
42: }
43: /**
44: * @return mixed
45: */
46: public function getRole()
47: {
48: $roles = Role::pluck('display_name', 'id')->except([User::ADMIN, User::DOCTOR,
49: User::PATIENT]);
50: return $roles;
51: }
52: public function store($input): bool
53: {
54: try {
55: DB::beginTransaction();
56: $input['email'] = setEmailLowerCase($input['email']);
57: $input['password'] = Hash::make($input['password']);
58: $input['type'] = User::STAFF;
59: $staff = User::create($input);
60: if (isset($input['role']) && ! empty($input['role'])) {
61: $role = $staff->assignRole($input['role']);
62: $role->givePermissionTo('manage_admin_dashboard');
63: }
64: if (isset($input['profile']) && ! empty($input['profile'])) {
65: $staff->addMedia($input['profile'])->toMediaCollection(Staff::PROFILE,
66: config('app.media_disc'));
67: }
68: DB::commit();
69: return true;
70: } catch (Exception $e) {
71: DB::rollBack();
72: throw new UnprocessableEntityHttpException($e->getMessage());
73: }
74: }
75: public function update($input, $id)
76: {
77: try {
78: DB::beginTransaction();
79: $staff = User::find($id);
80: $input['email'] = setEmailLowerCase($input['email']);
81: if (isset($input['password']) && ! empty($input['password'])) {
82: $input['password'] = Hash::make($input['password']);
83: } else {
84: unset($input['password']);
85: }
86: $input['type'] = User::STAFF;
87: $staff->update($input);
88: if (isset($input['role']) && ! empty($input['role'])) {
89: $staff->syncRoles($input['role']);
90: }
91: if (isset($input['profile']) && ! empty($input['profile'])) {
92: $staff->clearMediaCollection(Staff::PROFILE);
93: $staff->media()->delete();
94: $staff->addMedia($input['profile'])->toMediaCollection(Staff::PROFILE,
95: config('app.media_disc'));
96: }
97: DB::commit();
98: return true;
99: } catch (Exception $e) {
100: DB::rollBack();
101: throw new UnprocessableEntityHttpException($e->getMessage());
102: }
103: }
104: }
[app > Repositories > StateRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\State;
4: /**
5: * Class StateRepository
6: *
7: * @version July 29, 2021, 11:48 am UTC
8: */
9: class StateRepository extends BaseRepository
10: {
11: /**
12: * @var array
13: */
14: protected $fieldSearchable = [
15: 'name',
16: 'country_id',
17: ];
18: /**
19: * Return searchable fields
20: */
21: public function getFieldsSearchable(): array
22: {
23: return $this->fieldSearchable;
24: }
25: /**
26: * Configure the Model
27: **/
28: public function model()
29: {
30: return State::class;
31: }
32: }
[app > Repositories > TransactionRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Transaction;
4: /**
5: * Class RoleRepository
6: *
7: * @version August 5, 2021, 10:43 am UTC
8: */
9: class TransactionRepository extends BaseRepository
10: {
11: /**
12: * @var array
13: */
14: protected $fieldSearchable = [
15: 'name',
16: ];
17: /**
18: * Return searchable fields
19: */
20: public function getFieldsSearchable(): array
21: {
22: return $this->fieldSearchable;
23: }
24: /**
25: * Configure the Model
26: **/
27: public function model()
28: {
29: return Transaction::class;
30: }
31: public function show($id): array
32: {
33: $transaction['data'] = Transaction::with('user', 'appointment.doctor.user',
34: 'acceptedPaymentUser')->whereId($id)->first();
35: return $transaction;
36: }
37: }
[app > Repositories > UserRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\DataTable\UserDataTable;
4: use App\Models\Appointment;
5: use App\Models\Country;
6: use App\Models\Doctor;
7: use App\Models\DoctorSession;
8: use App\Models\Patient;
9: use App\Models\Qualification;
10: use App\Models\Specialization;
11: use App\Models\User;
12: use Arr;
13: use Carbon\Carbon;
14: use Hash;
15: use Illuminate\Support\Facades\Auth;
16: use Illuminate\Support\Facades\DB;
17: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
18: use Yajra\DataTables\DataTables;
19: use Illuminate\Support\Facades\Session;
20: use App\Models\Setting;
21: /**
22: * Class UserRepository
23: */
24: class UserRepository extends BaseRepository
25: {
26: public $fieldSearchable = [
27: 'first_name',
28: 'last_name',
29: 'email',
30: 'contact',
31: 'dob',
32: 'specialization',
33: 'experience',
34: 'gender',
35: 'status',
36: 'password',
37: ];
38: /**
39: * {@inheritDoc}
40: */
41: public function getFieldsSearchable()
42: {
43: return $this->fieldSearchable;
44: }
45: /**
46: * {@inheritDoc}
47: */
48: public function model()
49: {
50: return User::class;
51: }
52: /**
53: * @return mixed
54: */
55: public function store(array $input)
56: {
57: $addressInputArray = Arr::only($input,
58: ['address1', 'address2', 'country_id', 'city_id', 'state_id', 'postal_code']);
59: $doctorArray = Arr::only($input, ['experience', 'twitter_url', 'linkedin_url',
60: 'instagram_url']);
61: $specialization = $input['specializations'];
62: try {
63: DB::beginTransaction();
64: $input['email'] = setEmailLowerCase($input['email']);
65: $input['status'] = (isset($input['status'])) ? 1 : 0;
66: $input['password'] = Hash::make($input['password']);
67: $input['type'] = User::DOCTOR;
68: $input['language'] = Setting::where('key','language')->get()->toArray()[0]['value'];
69: $doctor = User::create($input);
70: $doctor->assignRole('doctor');
71: $doctor->address()->create($addressInputArray);
72: $createDoctor = $doctor->doctor()->create($doctorArray);
73: $createDoctor->specializations()->sync($specialization);
74: if (isset($input['profile']) && ! empty('profile')) {
75: $doctor->addMedia($input['profile'])->toMediaCollection(User::PROFILE,
76: config('app.media_disc'));
77: }
78: $doctor->sendEmailVerificationNotification();
79: DB::commit();
80: return $doctor;
81: } catch (\Exception $e) {
82: throw new UnprocessableEntityHttpException($e->getMessage());
83: }
84: }
85: public function update($input, $doctor)
86: {
87: $addressInputArray = Arr::only($input,
88: ['address1', 'address2', 'city_id', 'state_id', 'country_id', 'postal_code']);
89: $doctorArray = Arr::only($input, ['experience', 'twitter_url', 'linkedin_url',
90: 'instagram_url']);
91: $qualificationArray = json_decode($input['qualifications'], true);
92: $specialization = $input['specializations'];
93: try {
94: DB::beginTransaction();
95: $input['email'] = setEmailLowerCase($input['email']);
96: $input['status'] = (isset($input['status'])) ? 1 : 0;
97: $input['type'] = User::DOCTOR;
98: $doctor->user->update($input);
99: $doctor->user->address()->update($addressInputArray);
100: $doctor->update($doctorArray);
101: $doctor->specializations()->sync($specialization);
102: if (count($qualificationArray) >= 0) {
103: if (isset($input['deletedQualifications'])) {
104: Qualification::whereIn('id', explode(',',
$input['deletedQualifications']))->delete();
105: }
106: foreach ($qualificationArray as $qualifications) {
107: if ($qualifications == null) {
108: continue;
109: }
110: if (isset($qualifications['id'])) {
111: $doctor->user->qualifications()->where('id',
112: $qualifications['id'])->update($qualifications);
113: } else {
114: unset($qualifications['id']);
115: $doctor->user->qualifications()->create($qualifications);
116: }
117: }
118: }
119: if (isset($input['profile']) && ! empty('profile')) {
120: $doctor->user->clearMediaCollection(User::PROFILE);
121: $doctor->user->media()->delete();
122: $doctor->user->addMedia($input['profile'])->toMediaCollection(User::PROFILE,
123: config('app.media_disc'));
124: }
125: DB::commit();
126: return $doctor;
127: } catch (\Exception $e) {
128: throw new UnprocessableEntityHttpException($e->getMessage());
129: }
130: }
131: public function updateProfile(array $userInput): bool
132: {
133: try {
134: DB::beginTransaction();
135: $user = Auth::user();
136: $user->update($userInput);
137: if ((getLogInUser()->hasRole('patient'))) {
138: if (! empty($userInput['image'])) {
139: $user->clearMediaCollection(Patient::PROFILE);
140: $user->patient->media()->delete();
141: $user->patient->addMedia($userInput['image'])->toMediaCollection(Patient::PROFILE,
142: config('app.media_disc'));
143: }
144: } else {
145: if ((! empty($userInput['image']))) {
146: $user->clearMediaCollection(User::PROFILE);
147: $user->media()->delete();
148: $user->addMedia($userInput['image'])->toMediaCollection(User::PROFILE,
149: config('app.media_disc'));
150: }
151: }
152: DB::commit();
153: return true;
154: } catch (\Exception $e) {
155: DB::rollBack();
156: throw new UnprocessableEntityHttpException($e->getMessage());
157: }
158: }
159: /**
160: * @return mixed
161: */
162: public function getSpecializationsData($doctor)
163: {
164: $data['specializations'] = Specialization::pluck('name', 'id')->toArray();
165: $data['doctorSpecializations'] =
166: $doctor->specializations()->pluck('specialization_id')->toArray();
167: $data['countryId'] = $doctor->user->address()->pluck('country_id');
168: $data['stateId'] = $doctor->user->address()->pluck('state_id');
169: return $data;
170: }
171: /**
172: * @return mixed
173: */
174: public function getCountries()
175: {
176: $countries = Country::pluck('name', 'id');
177: return $countries;
178: }
179: public function addQualification($input)
180: {
181: $input['user_id'] = $input['id'];
182: $qualification = Qualification::create($input);
183: return $qualification;
184: }
185: /**
186: * @throws \Exception
187: */
188: public function doctorDetail($input): array
189: {
190: $todayDate = Carbon::now()->format('Y-m-d');
191: $doctor['data'] = Doctor::with(['user.address', 'specializations',
192: 'appointments.patient.user'])->whereId($input->id)->first();
193: $doctor['doctorSession'] = DoctorSession::whereDoctorId($input->id)->get();
194: // $doctor['appointments'] = DataTables::of((new
195: UserDataTable())->getAppointment($input->id))->make(true);
196: $doctor['appointmentStatus'] = Appointment::ALL_STATUS;
197: $doctor['totalAppointmentCount'] = Appointment::whereDoctorId($input->id)->count();
198: $doctor['todayAppointmentCount'] =
Appointment::whereDoctorId($input->id)->where('date',
199: '=',
200: $todayDate)->count();
201: $doctor['upcomingAppointmentCount'] =
202: Appointment::whereDoctorId($input->id)->where('date', '>',
203: $todayDate)->count();
204: return $doctor;
205: }
206: }
[app > Repositories > VisitRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\Doctor;
4: use App\Models\Patient;
5: use App\Models\Visit;
6: use Illuminate\Database\Eloquent\Builder;
7: use Illuminate\Database\Eloquent\Collection;
8: use Illuminate\Database\Eloquent\Model;
9: /**
10: * Class EncounterRepository
11: *
12: * @version September 3, 2021, 7:09 am UTC
13: */
14: class VisitRepository extends BaseRepository
15: {
16: /**
17: * @var array
18: */
19: protected $fieldSearchable = [
20: 'visit_date',
21: 'doctor',
22: 'patient',
23: 'description',
24: ];
25: /**
26: * Return searchable fields
27: */
28: public function getFieldsSearchable(): array
29: {
30: return $this->fieldSearchable;
31: }
32: /**
33: * Configure the Model
34: **/
35: public function model()
36: {
37: return Visit::class;
38: }
39: public function getData(): array
40: {
41: $data['doctors'] = Doctor::with('user')->get()->where('user.status',
42: true)->pluck('user.full_name', 'id');
43: $data['patients'] = Patient::with('user')->get()->pluck('user.full_name', 'id');
44: return $data;
45: }
46: public function update($input, $encounter): bool
47: {
48: $encounter->update($input);
49: return true;
50: }
51: /**
52: * @return Builder|Builder[]|Collection|Model|null
53: */
54: public function getShowData($id)
55: {
56: return Visit::with([
57: 'visitDoctor.user', 'visitPatient.user', 'problems', 'observations', 'notes',
58: 'prescriptions',
59: ])->findOrFail($id);
60: }
61: }
[app > Repositories > ZoomRepository.php]
1: <?php
2: namespace App\Repositories;
3: use App\Models\LiveConsultation;
4: use App\Models\ZoomOAuth;
5: use GuzzleHttp\Client;
6: use Illuminate\Support\Facades\Auth;
7: use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
8: /**
9: * Class ZoomRepository
10: */
11: class ZoomRepository
12: {
13: public function connectWithZoom($code)
14: {
15: $userZoomCredential = \App\Models\UserZoomCredential::where('user_id',
16: getLogInUserId())->first();
17: $clientID = $userZoomCredential->zoom_api_key;
18: $secret = $userZoomCredential->zoom_api_secret;
19: $client = new Client(['base_uri' => 'https://zoom.us']);
20: $response = $client->request('POST', '/oauth/token', [
21: 'headers' => [
22: 'Authorization' => 'Basic '.base64_encode($clientID.':'.$secret),
23: ],
24: 'form_params' => [
25: 'grant_type' => 'authorization_code',
26: 'code' => $code,
27: 'redirect_uri' => config('app.zoom_callback'),
28: ],
29: ]);
30: $token = json_decode($response->getBody()->getContents(), true);
31: $exist = ZoomOAuth::where('user_id', Auth::id())->first();
32: if (! $exist) {
33: ZoomOAuth::create([
34: 'user_id' => Auth::id(),
35: 'access_token' => $token['access_token'],
36: 'refresh_token' => $token['refresh_token'],
37: ]);
38: } else {
39: $exist->update([
40: 'access_token' => $token['access_token'],
41: 'refresh_token' => $token['refresh_token'],
42: ]);
43: }
44: return true;
45: }
46: public function updateZoomMeeting($data, $liveConsultation)
47: {
48: $client = new Client(['base_uri' => 'https://api.zoom.us']);
49: $zoomOAuth = ZoomOAuth::where('user_id', Auth::id())->first();
50: try {
51: $response = $client->request('PATCH', 'v2/meetings/'.$liveConsultation->meeting_id, [
52: 'headers' => [
53: 'Authorization' => 'Bearer '.$zoomOAuth->access_token,
54: ],
55: 'json' => [
56: 'topic' => $data['consultation_title'],
57: 'type' => 2,
58: 'start_time' => $this->toZoomTimeFormat($data['consultation_date']),
59: 'duration' => $data['consultation_duration_minutes'],
60: 'agenda' => (! empty($data['description'])) ? $data['description'] : null,
61: 'password' => '123456',
62: 'settings' => [
63: 'host_video' => ($data['host_video'] == LiveConsultation::HOST_ENABLE) ? true :
false,
64: 'participant_video' => ($data['participant_video'] ==
LiveConsultation::CLIENT_ENABLE) ?
65: true : false,
66: 'waiting_room' => true,
67: ],
68: ],
69: ]);
70: $data = json_decode($response->getBody());
71: return (array) $data;
72: } catch (\Exception $e) {
73: throw new UnprocessableEntityHttpException($e->getMessage());
74: }
75: }
76: public function createZoomMeeting($data)
77: {
78: $client = new Client(['base_uri' => 'https://api.zoom.us']);
79: $zoomOAuth = ZoomOAuth::where('user_id', Auth::id())->first();
80: try {
81: $response = $client->request('POST', '/v2/users/me/meetings', [
82: 'headers' => [
83: 'Authorization' => 'Bearer '.$zoomOAuth->access_token,
84: ],
85: 'json' => [
86: 'topic' => $data['consultation_title'],
87: 'type' => 2,
88: 'start_time' => $this->toZoomTimeFormat($data['consultation_date']),
89: 'duration' => $data['consultation_duration_minutes'],
90: 'agenda' => (! empty($data['description'])) ? $data['description'] : null,
91: 'password' => '123456',
92: 'settings' => [
93: 'host_video' => ($data['host_video'] == LiveConsultation::HOST_ENABLE) ? true :
false,
94: 'participant_video' => ($data['participant_video'] ==
LiveConsultation::CLIENT_ENABLE) ?
95: true : false,
96: 'waiting_room' => true,
97: ],
98: ],
99: ]);
100: $data = json_decode($response->getBody());
101: return (array) $data;
102: } catch (\Exception $e) {
103: if (401 == $e->getCode()) {
104: $refresh_token = $zoomOAuth->refresh_token;
105: $client = new Client(['base_uri' => 'https://zoom.us']);
106: $response = $client->request('POST', '/oauth/token', [
107: 'headers' => [
108: 'Authorization' => 'Basic '.base64_encode($clientID.':'.$secret),
109: ],
110: 'form_params' => [
111: 'grant_type' => 'refresh_token',
112: 'refresh_token' => $refresh_token,
113: ],
114: ]);
115: $zoomOAuth->update(['refresh_token' => $response->getBody()]);
116: $this->createZoomMeeting($data);
117: } else {
118: throw new UnprocessableEntityHttpException($e->getMessage());
119: }
120: }
121: }
122: public function toZoomTimeFormat(string $dateTime)
123: {
124: try {
125: $date = new \DateTime($dateTime);
126: return $date->format('Y-m-d\TH:i:s');
127: } catch (\Exception $e) {
128: \Log::error('ZoomJWT->toZoomTimeFormat : '.$e->getMessage());
129: return '';
130: }
131: }
132: public function zoomGet($id)
133: {
134: $liveCunsultation = LiveConsultation::whereMeetingId($id)->first();
135: $client = new Client(['base_uri' => 'https://api.zoom.us']);
136: $zoomOAuth = ZoomOAuth::where('user_id', $liveCunsultation->created_by)->first();
137: $response = $client->request('GET', '/v2/meetings/'.$id, [
138: 'headers' => [
139: 'Authorization' => 'Bearer '.$zoomOAuth->access_token,
140: ],
141: ]);
142: $data = json_decode($response->getBody());
143: return $data;
144: }
145: public function destroyZoomMeeting($meetingId)
146: {
147: $clientID = config('app.zoom_api_key');
148: $secret = config('app.zoom_api_secret');
149: $client = new Client(['base_uri' => 'https://api.zoom.us']);
150: $zoomOAuth = ZoomOAuth::where('user_id', Auth::id())->first();
151: try {
152: $response = $client->request('DELETE', '/v2/meetings/'.$meetingId, [
153: 'headers' => [
154: 'Authorization' => 'Bearer '.$zoomOAuth->access_token,
155: ],
156: ]);
157: $data = json_decode($response->getBody());
158: return $data;
159: } catch (\Exception $e) {
160: throw new UnprocessableEntityHttpException($e->getMessage());
161: }
162: }
163: }
[app > Utils > ResponseUtil.php]
1: <?php
2: namespace App\Utils;
3: class ResponseUtil
4: {
5: /**
6: * @param mixed $data
7: */
8: public static function makeResponse(string $message, $data): array
9: {
10: return [
11: 'success' => true,
12: 'data' => $data,
13: 'message' => $message,
14: ];
15: }
16: public static function makeError(string $message, array $data = []): array
17: {
18: $res = [
19: 'success' => false,
20: 'message' => $message,
21: ];
22: if (! empty($data)) {
23: $res['data'] = $data;
24: }
25: return $res;
26: }
27: }
[View > Components > AppLayout.php]
1: <?php
2: namespace App\View\Components;
3: use Illuminate\View\Component;
4: use Illuminate\View\View;
5: class AppLayout extends Component
6: {
7: /**
8: * Get the view / contents that represents the component.
9: */
10: public function render(): View
11: {
12: return view('layouts.app');
13: }
14: }
[View > Components > CreateForm.php]
1: <?php
2: namespace App\View\Components;
3: use Illuminate\Contracts\Foundation\Application;
4: use Illuminate\Contracts\View\Factory;
5: use Illuminate\Contracts\View\View;
6: use Illuminate\View\Component;
7: class CreateForm extends Component
8: {
9: public $title;
10: public $back;
11: public $id;
12: public $route;
13: public $fields;
14: /**
15: * @var false
16: */
17: public bool $files;
18: public string $method;
19: /**
20: * Create a new component instance.
21: *
22: * @return void
23: */
24: public function __construct(
25: $title,
26: $back,
27: $id,
28: $route,
29: $fields,
30: $files = false,
31: $method = 'post'
32: ) {
33: $this->title = $title;
34: $this->back = $back;
35: $this->id = $id;
36: $this->route = $route;
37: $this->fields = $fields;
38: $this->files = $files;
39: $this->method = $method;
40: }
41: /**
42: * Get the view / contents that represent the component.
43: *
44: * @return Application|Factory|View
45: */
46: public function render()
47: {
48: return view('components.create-form');
49: }
50: }
[View > Components > EditForm.php]
1: <?php
2: namespace App\View\Components;
3: use Illuminate\View\Component;
4: class EditForm extends Component
5: {
6: public $title;
7: public $back;
8: public $id;
9: public $route;
10: public $fields;
11: /**
12: * @var false
13: */
14: public bool $files;
15: private string $method;
16: private $recordID;
17: /**
18: * Create a new component instance.
19: *
20: * @return void
21: */
22: public function __construct(
23: $title,
24: $back,
25: $id,
26: $recordID,
27: $route,
28: $fields,
29: $files = false,
30: $method = 'post'
31: ) {
32: $this->title = $title;
33: $this->back = $back;
34: $this->recordID = $recordID;
35: $this->id = $id;
36: $this->route = $route;
37: $this->fields = $fields;
38: $this->files = $files;
39: $this->method = $method;
40: }
41: /**
42: * Get the view / contents that represent the component.
43: *
44: * @return \Illuminate\Contracts\View\View|\Closure|string
45: */
46: public function render()
47: {
48: return view('components.edit-form')->with(['method' => $this->method, 'recordID' =>
49: $this->recordID]);
50: }
51: }
[View > Components > ErrorBox.php]
1: <?php
2: namespace App\View\Components;
3: use Illuminate\Contracts\Foundation\Application;
4: use Illuminate\Contracts\View\Factory;
5: use Illuminate\Contracts\View\View;
6: use Illuminate\View\Component;
7: class ErrorBox extends Component
8: {
9: public $error;
10: /**
11: * Create a new component instance.
12: *
13: * @return void
14: */
15: public function __construct($error)
16: {
17: $this->error = $error;
18: }
19: /**
20: * Get the view / contents that represent the component.
21: *
22: * @return Application|Factory|View
23: */
24: public function render()
25: {
26: return view('components.error-box');
27: }
28: }
[View > Components > GuestLayout.php]
1: <?php
2: namespace App\View\Components;
3: use Illuminate\View\Component;
4: use Illuminate\View\View;
5: class GuestLayout extends Component
6: {
7: /**
8: * Get the view / contents that represents the component.
9: */
10: public function render(): View
11: {
12: return view('layouts.guest');
13: }
14: }

You might also like