firstcommit

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

View File

@@ -0,0 +1,107 @@
<?php
namespace Modules\Appointment\app\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Modules\Appointment\app\Repositories\AppointmentRepository;
use Modules\Appointment\app\Http\Requests\CreateAppointmentRequest;
class AppointmentController extends Controller
{
protected $appointmentRepository;
public function __construct()
{
$this->appointmentRepository = new AppointmentRepository;
}
/**
* Display a listing of the resource.
*/
public function index(Request $request)
{
$perPage = $request->has('per-page') ? $request->input('per-page') : null;
$filter = $request->has('filter') ? $request->input('filter') : [];
$data['appointments'] = $this->appointmentRepository->allAppointmentList($perPage, $filter);
$data['appointmentCount'] = $data['appointments']->count();
return view('appointment::index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('appointment::create');
}
/**
* Store a newly created resource in storage.
*/
public function store(CreateAppointmentRequest $request): RedirectResponse
{
try {
$validated = $request->validated();
$this->appointmentRepository->storeAppointmentList($validated);
toastr()->success('Appointment created successfully.');
return redirect()->route('doctor_provider');
} catch (\Throwable $th) {
report($th);
toastr()->error('Something went wrong.');
return back();
}
}
/**
* Show the specified resource.
*/
public function show($uuid)
{
$data['appointment'] = $this->appointmentRepository->findAppointmentListById($uuid);
return view('appointment::show', $data);
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
return view('appointment::edit');
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy($uuid)
{
try {
$appointment = $this->appointmentRepository->deleteAppointmentList($uuid);
if (!$appointment) {
toastr()->error('Appointment not found.');
return back();
}
toastr()->success('Appointment deleted successfully.');
return redirect()->route('cms.appointment.index');
} catch (\Throwable $th) {
report($th);
toastr()->error('Something went wrong.');
return back();
}
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace Modules\Appointment\app\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class CreateAppointmentRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
return [
'team_member_id' => 'required|integer',
'full_name' => 'required|string|max:150',
'email' => 'required|email',
'contact_no' => 'required|string',
'subject' => 'required|string|max:500',
'feedback' => 'required|string',
];
}
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
}

View File

View File

@@ -0,0 +1,39 @@
<?php
namespace Modules\Appointment\app\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Modules\Appointment\Database\factories\AppointmentFactory;
use Modules\TeamMember\app\Models\TeamMember;
class Appointment extends Model
{
use HasFactory;
use SoftDeletes;
/**
* The attributes that are mass assignable.
*/
protected $fillable = [
'uuid',
'team_member_id',
'full_name',
'email',
'contact_no',
'subject',
'feedback',
];
protected static function newFactory(): AppointmentFactory
{
//return AppointmentFactory::new();
}
public function doctorDetail()
{
return $this->belongsTo(TeamMember::class, 'team_member_id');
}
}

View File

@@ -0,0 +1,114 @@
<?php
namespace Modules\Appointment\app\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class AppointmentServiceProvider extends ServiceProvider
{
protected string $moduleName = 'Appointment';
protected string $moduleNameLower = 'appointment';
/**
* Boot the application events.
*/
public function boot(): void
{
$this->registerCommands();
$this->registerCommandSchedules();
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
$this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations'));
}
/**
* Register the service provider.
*/
public function register(): void
{
$this->app->register(RouteServiceProvider::class);
}
/**
* Register commands in the format of Command::class
*/
protected function registerCommands(): void
{
// $this->commands([]);
}
/**
* Register command Schedules.
*/
protected function registerCommandSchedules(): void
{
// $this->app->booted(function () {
// $schedule = $this->app->make(Schedule::class);
// $schedule->command('inspire')->hourly();
// });
}
/**
* Register translations.
*/
public function registerTranslations(): void
{
$langPath = resource_path('lang/modules/'.$this->moduleNameLower);
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
$this->loadJsonTranslationsFrom($langPath);
} else {
$this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower);
$this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang'));
}
}
/**
* Register config.
*/
protected function registerConfig(): void
{
$this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config');
$this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower);
}
/**
* Register views.
*/
public function registerViews(): void
{
$viewPath = resource_path('views/modules/'.$this->moduleNameLower);
$sourcePath = module_path($this->moduleName, 'resources/views');
$this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']);
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
$componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path'));
Blade::componentNamespace($componentNamespace, $this->moduleNameLower);
}
/**
* Get the services provided by the provider.
*/
public function provides(): array
{
return [];
}
private function getPublishableViewPaths(): array
{
$paths = [];
foreach (config('view.paths') as $path) {
if (is_dir($path.'/modules/'.$this->moduleNameLower)) {
$paths[] = $path.'/modules/'.$this->moduleNameLower;
}
}
return $paths;
}
}

View File

@@ -0,0 +1,59 @@
<?php
namespace Modules\Appointment\app\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* The module namespace to assume when generating URLs to actions.
*/
protected string $moduleNamespace = 'Modules\Appointment\app\Http\Controllers';
/**
* Called before routes are registered.
*
* Register any model bindings or pattern based filters.
*/
public function boot(): void
{
parent::boot();
}
/**
* Define the routes for the application.
*/
public function map(): void
{
$this->mapApiRoutes();
$this->mapWebRoutes();
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*/
protected function mapWebRoutes(): void
{
Route::middleware('web')
->namespace($this->moduleNamespace)
->group(module_path('Appointment', '/routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*/
protected function mapApiRoutes(): void
{
Route::prefix('api')
->middleware('api')
->namespace($this->moduleNamespace)
->group(module_path('Appointment', '/routes/api.php'));
}
}

View File

@@ -0,0 +1,81 @@
<?php
namespace Modules\Appointment\app\Repositories;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\DB;
use Modules\Appointment\app\Models\Appointment;
class AppointmentRepository
{
public function allAppointmentList($perPage = null, $filter = [], $sort = ['by' => 'id', 'sort' => 'DESC'])
{
return Appointment::with('doctorDetail')->when(array_keys($filter, true), function ($query) use ($filter) {
if (!empty($filter['email'])) {
$query->where('email', $filter['email']);
}
})
->orderBy($sort['by'], $sort['sort'])
->paginate($perPage ?: env('PAGE_LIMIT', 999));
}
public function findAppointmentListById($uuid)
{
return Appointment::where('uuid', $uuid)->first();
}
public function storeAppointmentList($validated)
{
DB::beginTransaction();
try {
$appointment = new Appointment();
$appointment->uuid = Str::uuid();
$appointment->team_member_id = $validated['team_member_id'];
$appointment->full_name = $validated['full_name'];
$appointment->email = $validated['email'];
$appointment->contact_no = $validated['contact_no'];
$appointment->subject = $validated['subject'];
$appointment->feedback = $validated['feedback'];
if($appointment->save()) {
$from = $appointment->email;
$to = "info@aroginhealthcare.com";
$subject = $appointment->subject;
$message = $appointment->feedback;
$headers = "From:" . $from;
mail($to,$subject,$message, $headers);
}
DB::commit();
return $appointment;
} catch (\Throwable $th) {
report($th);
DB::rollback();
return null;
}
}
public function deleteAppointmentList($uuid)
{
DB::beginTransaction();
try {
$appointment = $this->findAppointmentListById($uuid);
if (!$appointment) {
return null;
}
$appointment->delete();
DB::commit();
return true;
} catch (\Throwable $th) {
DB::rollback();
report($th);
return null;
}
}
}

View File

@@ -0,0 +1,31 @@
{
"name": "nwidart/appointment",
"description": "",
"authors": [
{
"name": "Nicolas Widart",
"email": "n.widart@gmail.com"
}
],
"extra": {
"laravel": {
"providers": [],
"aliases": {
}
}
},
"autoload": {
"psr-4": {
"Modules\\Appointment\\": "",
"Modules\\Appointment\\App\\": "app/",
"Modules\\Appointment\\Database\\Factories\\": "database/factories/",
"Modules\\Appointment\\Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Modules\\Appointment\\Tests\\": "tests/"
}
}
}

View File

View File

@@ -0,0 +1,5 @@
<?php
return [
'name' => 'Appointment',
];

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('appointments', function (Blueprint $table) {
$table->id();
$table->uuid();
$table->unsignedBigInteger('team_member_id');
$table->string('full_name');
$table->string('email');
$table->string('contact_no');
$table->text('subject');
$table->text('feedback');
$table->softDeletes();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('appointments');
}
};

View File

@@ -0,0 +1,59 @@
<?php
namespace Modules\Appointment\database\seeders;
use Illuminate\Support\Str;
use Illuminate\Database\Seeder;
use Modules\Appointment\app\Models\Appointment;
class AppointmentDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$appointments = [
[
'team_member_id' => '1',
'full_name' => 'Jhon Doe',
'email' => 'jhondoe@xyz.com',
'contact_no' => '+9779800236532',
'subject' => 'Appointment Request For Follow-up',
'feedback' => "Dear Dr. Johnson,I hope this email finds you in good health. I am writing to request an appointment with you for my annual check-up.
Preferred Date: April 10th, 2024
Preferred Time: Anytime between 10:00 AM and 2:00 PM
Please let me know if any of the mentioned time slots are available or suggest an alternative that suits your schedule. Additionally, if there are any specific preparations I need to make before the appointment, kindly inform me.
Thank you for your attention to this matter. I appreciate your prompt response.
Warm regards,
Jhon Doe",
],
[
'team_member_id' => '2',
'full_name' => 'Sudarshan Shrestha',
'email' => 'sudarshansth@xyz.com',
'contact_no' => '+9779800236533',
'subject' => 'Appointment Request To Consult About Brain Tumor',
'feedback' => "Dear Dr. Sita Sakya,I hope this email finds you in good health. I am writing to request an appointment with you for my annual check-up.
Preferred Date: December 10th, 2024
Preferred Time: Anytime between 10:00 AM and 2:00 PM
Please let me know if any of the mentioned time slots are available or suggest an alternative that suits your schedule. Additionally, if there are any specific preparations I need to make before the appointment, kindly inform me.
Thank you for your attention to this matter. I appreciate your prompt response.
Warm regards,
Sudarshan Shrestha",
],
];
foreach ($appointments as $appointment) {
$appointment = Appointment::create([
'uuid' => Str::uuid(),
'team_member_id' => $appointment['team_member_id'],
'full_name' => $appointment['full_name'],
'email' => $appointment['email'],
'contact_no' => $appointment['contact_no'],
'subject' => $appointment['subject'],
'feedback' => $appointment['feedback'],
]);
}
}
}

View File

View File

@@ -0,0 +1,11 @@
{
"name": "Appointment",
"alias": "appointment",
"description": "",
"keywords": [],
"priority": 0,
"providers": [
"Modules\\Appointment\\app\\Providers\\AppointmentServiceProvider"
],
"files": []
}

View File

@@ -0,0 +1,15 @@
{
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"axios": "^1.1.2",
"laravel-vite-plugin": "^0.7.5",
"sass": "^1.69.5",
"postcss": "^8.3.7",
"vite": "^4.0.0"
}
}

View File

@@ -0,0 +1,119 @@
@extends('admin::layouts.master')
@section('title')
Appointment
@endsection
@section('breadcrumb')
@php
$breadcrumbData = [
[
'title' => 'Appointment',
'link' => 'null',
],
[
'title' => 'Dashboard',
'link' => route('dashboard'),
],
[
'title' => 'Appointments',
'link' => null,
],
];
@endphp
@include('admin::layouts.partials.breadcrumb', $breadcrumbData)
@endsection
@section('content')
<!-- banners List Table -->
<div class="card">
<div class="row">
<div class="col-md-6">
<h4 class="card-header">List of Appointment</h4>
</div>
</div>
<div class="card-datatable table-responsive">
<table class="table">
<thead class="table-light">
<tr>
<th>S.N</th>
<th>Full Name With Subject</th>
<th>Doctor</th>
<th>Contact No.</th>
<th>Email</th>
<th>Created At</th>
<th>Actions</th>
</tr>
</thead>
<tbody class="table-border-bottom-0">
@if ($appointmentCount > 0)
@foreach ($appointments ?? [] as $appointment)
<tr>
<td>
#{{ $loop->iteration }}
</td>
<td>
<div class="d-flex align-items-center me-3">
<div class="card-title mb-0 px-3">
<h6 class="mb-0"> {{ $appointment->full_name }}</h6>
<small class="text-muted">{{ Str::limit($appointment->subject, 80) }}</small>
</div>
</div>
</td>
<td>
{{ optional($appointment->doctorDetail)->name }}
</td>
<td>
{{ $appointment->contact_no }}
</td>
<td>
{{ $appointment->email }}
</td>
<td>
{{ $appointment->created_at->toFormattedDateString() }}
</td>
<td>
<div class="d-flex">
<form method="POST"
action="{{ route('cms.appointment.show', ['uuid' => $appointment->uuid]) }}"
class="dropdown-item">
@csrf
<button type="submit" class="border-0 bg-transparent viewBtn"
style="color:inherit"><i class="bx bx-show-alt me-1"></i></button>
</form>
<form method="POST"
action="{{ route('cms.appointment.delete', ['uuid' => $appointment->uuid]) }}"
id="deleteForm_{{ $appointment->uuid }}" class="dropdown-item">
@csrf
@method('DELETE')
<button type="submit" class="border-0 bg-transparent deleteBtn"
style="color:inherit"><i class="bx bx-trash me-1"></i></button>
</form>
</div>
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="7">No record found.</td>
</tr>
@endif
</tbody>
</table>
</div>
<div class="px-3">
{{-- {{ $appointment->links('admin::layouts.partials.pagination') }} --}}
</div>
</div>
@endsection
{{-- style --}}
@push('required-styles')
@include('admin::vendor.dataTables.style')
@endpush
{{-- script --}}
@push('required-scripts')
@include('admin::vendor.dataTables.script')
@endpush

View File

@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Appointment Module - {{ config('app.name', 'Laravel') }}</title>
<meta name="description" content="{{ $description ?? '' }}">
<meta name="keywords" content="{{ $keywords ?? '' }}">
<meta name="author" content="{{ $author ?? '' }}">
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
{{-- Vite CSS --}}
{{-- {{ module_vite('build-appointment', 'resources/assets/sass/app.scss') }} --}}
</head>
<body>
@yield('content')
{{-- Vite JS --}}
{{-- {{ module_vite('build-appointment', 'resources/assets/js/app.js') }} --}}
</body>

View File

@@ -0,0 +1,77 @@
@extends('admin::layouts.master')
@section('title')
Appointment Message
@endsection
@section('breadcrumb')
@php
$breadcrumbData = [
[
'title' => 'Appointment Message',
'link' => 'null',
],
[
'title' => 'Dashboard',
'link' => route('dashboard'),
],
[
'title' => 'Appointment Message',
'link' => null,
],
];
@endphp
@include('admin::layouts.partials.breadcrumb', $breadcrumbData)
@endsection
@section('content')
<!-- banners List Table -->
<div class="card">
<div class="row">
<div class="col-md-6">
<h4 class="card-header">Appointment Message</h4>
</div>
</div>
<div class="card">
<div class="card-header">
<h5> Appointment Requested By {{ $appointment->full_name ?? 'N/A' }}</h5>
</div>
<div class="modal-body">
<table class="table">
<tbody>
<tr>
<th>Name:</th>
<td>{{ $appointment->full_name ?? 'N/A' }}</td>
</tr>
<tr>
<th>Email:</th>
<td>{{ $appointment->email ?? 'N/A' }}</td>
</tr>
<tr>
<th>Contact No.:</th>
<td>{{ $appointment->contact_no ?? 'N/A' }}</td>
</tr>
<tr>
<th>Doctor:</th>
<td>{{ $appointment->doctorDetail->name ?? 'N/A' }}</td>
</tr>
<tr>
<th>Subject:</th>
<td>{{ $appointment->subject ?? 'N/A' }}</td>
</tr>
<tr>
<th>Message:</th>
<td>{{ $appointment->feedback ?? 'N/A' }}</td>
</tr>
</tbody>
</table>
</div>
<div class="card-footer">
<a href="{{ route('cms.appointment.index') }}" class="btn btn-secondary">Close</a>
</div>
</div>
</div>
@endsection

View File

View File

@@ -0,0 +1,19 @@
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::middleware(['auth:sanctum'])->prefix('v1')->name('api.')->group(function () {
Route::get('appointment', fn (Request $request) => $request->user())->name('appointment');
});

View File

@@ -0,0 +1,40 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Appointment\app\Http\Controllers\AppointmentController;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::group(
[
'prefix' => 'apanel',
'middleware' => ['auth'],
'as' => 'cms.',
],
function () {
Route::group(
[
'prefix' => 'cms',
'as' => 'appointment.',
'controller' => 'AppointmentController',
],
function () {
Route::get('appointment', 'index')->name('index');
Route::post('appointment/{uuid}', 'show')->name('show');
Route::delete('appointment/{uuid}/delete', 'destroy')->name('delete');
}
);
}
);
Route::post('/doctor-provider/make-appointment', 'AppointmentController@store')->name('make-appointment');

View File

View File

@@ -0,0 +1,26 @@
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
build: {
outDir: '../../public/build-appointment',
emptyOutDir: true,
manifest: true,
},
plugins: [
laravel({
publicDirectory: '../../public',
buildDirectory: 'build-appointment',
input: [
__dirname + '/resources/assets/sass/app.scss',
__dirname + '/resources/assets/js/app.js'
],
refresh: true,
}),
],
});
//export const paths = [
// 'Modules/$STUDLY_NAME$/resources/assets/sass/app.scss',
// 'Modules/$STUDLY_NAME$/resources/assets/js/app.js',
//];