firstcommit

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

View File

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

View File

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

View File

View File

@@ -0,0 +1,61 @@
<?php
namespace Modules\Consultation\app\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Modules\Consultation\Database\factories\ConsultationFactory;
class Consultation extends Model
{
use HasFactory;
const AGE_GROUP_OPTIONS = [
1 => 'Age 18-24',
2 => 'Age 25-34',
3 => 'Age 35-44',
4 => 'Age 45-54',
5 => 'Age 55 and above',
// 6 => 'Age 65-74',
// 7 => 'Age 75 and Up'
];
const PROCEDURE_OPTIONS = [
1 => 'Hair Transplant',
2 => 'Beard Transplant',
3 => 'Eyebrow Transplant',
4 => 'Platelet Rich Plasma Therapy (PRP)',
5 => 'Growth Factor Concentrate Therapy (GFC)'
];
/**
* The attributes that are mass assignable.
*/
protected $fillable = [
'uuid',
'name',
'email',
'contact_no',
'age_group',
'procedure_of_interest',
'subject',
'message',
'is_aggrement',
];
protected static function newFactory(): ConsultationFactory
{
//return ConsultationFactory::new();
}
public function ageGroupOption()
{
return self::AGE_GROUP_OPTIONS[$this->age_group];
}
public function procedureOfInterestOption()
{
return self::PROCEDURE_OPTIONS[$this->procedure_of_interest];
}
}

View File

@@ -0,0 +1,114 @@
<?php
namespace Modules\Consultation\app\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class ConsultationServiceProvider extends ServiceProvider
{
protected string $moduleName = 'Consultation';
protected string $moduleNameLower = 'consultation';
/**
* 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\Consultation\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\Consultation\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('Consultation', '/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('Consultation', '/routes/api.php'));
}
}

View File

@@ -0,0 +1,76 @@
<?php
namespace Modules\Consultation\app\Repositories;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\DB;
use Modules\Consultation\app\Models\Consultation;
class ConsultationRepository
{
public function allConsultationList($perPage = null, $filter = [], $sort = ['by' => 'id', 'sort' => 'DESC'])
{
return Consultation::when(array_keys($filter, true), function ($query) use ($filter) {
if (!empty($filter['contact_no'])) {
$query->where('contact_no', $filter['contact_no']);
}
})
->orderBy($sort['by'], $sort['sort'])
->paginate($perPage ?: env('PAGE_LIMIT', 999));
}
public function findConsultationListById($uuid)
{
return Consultation::where('uuid', $uuid)->first();
}
public function storeConsultationList($validated)
{
DB::beginTransaction();
try {
$consultation = new Consultation();
$consultation->uuid = Str::uuid();
$consultation->name = $validated['name'];
$consultation->email = $validated['email'] ?? null;
$consultation->contact_no = $validated['contact_no'];
$consultation->age_group = $validated['age_group'];
$consultation->procedure_of_interest = $validated['procedure_of_interest'];
$consultation->subject = $validated['subject'];
$consultation->message = $validated['message'];
$consultation->is_aggrement = $validated['is_aggrement'] ?? 10;
$consultation->save();
DB::commit();
return $consultation;
} catch (\Throwable $th) {
report($th);
DB::rollback();
return null;
}
}
public function deleteConsultationList($uuid)
{
DB::beginTransaction();
try {
$consultation = $this->findConsultationListById($uuid);
if (!$consultation) {
return null;
}
$consultation->delete();
DB::commit();
return true;
} catch (\Throwable $th) {
DB::rollback();
report($th);
return null;
}
}
}

View File

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

View File

View File

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

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('consultations', function (Blueprint $table) {
$table->id();
$table->uuid();
$table->string('name');
$table->string('email')->nullable();
$table->string('contact_no');
$table->unsignedTinyInteger('age_group');
$table->unsignedTinyInteger('procedure_of_interest');
$table->text('subject');
$table->text('message');
$table->string('is_aggrement');
$table->softDeletes();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('consultations');
}
};

View File

@@ -0,0 +1,60 @@
<?php
namespace Modules\Consultation\database\seeders;
use Illuminate\Support\Str;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class ConsultationDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$consultations = [
[
'uuid' => Str::uuid(),
'name' => 'John Doe',
'email' => 'john@example.com',
'contact_no' => '9846325698',
'age_group' => 2,
'procedure_of_interest' => 1,
'subject' => 'Hair Consultation',
'message' => 'I\'m interested in hair...',
'is_aggrement' => 11,
'created_at' => now(),
'updated_at' => now(),
],
[
'uuid' => Str::uuid(),
'name' => 'Hari Sharma',
'email' => 'hari@example.com',
'contact_no' => '9846325120',
'age_group' => 3,
'procedure_of_interest' => 2,
'subject' => 'Beard Consultation',
'message' => 'I\'m interested in beard traspalant...',
'is_aggrement' => 11,
'created_at' => now(),
'updated_at' => now(),
], [
'uuid' => Str::uuid(),
'name' => 'Gita Shrestha',
'email' => 'gita@example.com',
'contact_no' => '9813652365',
'age_group' => 1,
'procedure_of_interest' => 3,
'subject' => '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!',
'message' => 'I\'m interested in eyebrow transpalant.',
'is_aggrement' => 10,
'created_at' => now(),
'updated_at' => now(),
],
];
DB::table('consultations')->insert($consultations);
}
}

View File

View File

@@ -0,0 +1,11 @@
{
"name": "Consultation",
"alias": "consultation",
"description": "",
"keywords": [],
"priority": 0,
"providers": [
"Modules\\Consultation\\app\\Providers\\ConsultationServiceProvider"
],
"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,125 @@
@extends('admin::layouts.master')
@section('title')
Consultation
@endsection
@section('breadcrumb')
@php
$breadcrumbData = [
[
'title' => 'Consultation',
'link' => 'null',
],
[
'title' => 'Dashboard',
'link' => route('dashboard'),
],
[
'title' => 'Consultations',
'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 Consultation</h4>
</div>
</div>
<div class="card-datatable table-responsive">
<table class="table">
<thead class="table-light">
<tr>
<th>S.N</th>
<th>Name With Subject</th>
<th>Age</th>
<th>Procedure</th>
<th>Contact No.</th>
<th>Email</th>
<th>Created At</th>
<th>Actions</th>
</tr>
</thead>
<tbody class="table-border-bottom-0">
@if ($consultationCount > 0)
@foreach ($consultations ?? [] as $consultation)
<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"> {{ $consultation->name }}</h6>
<small class="text-muted">{{ Str::limit($consultation->subject, 50) }}</small>
</div>
</div>
</td>
<td>
{{ $consultation->ageGroupOption() }}
</td>
<td>
{{ $consultation->procedureOfInterestOption() }}
</td>
<td>
{{ $consultation->contact_no }}
</td>
<td>
{{ $consultation->email }}
</td>
<td>
{{ $consultation->created_at->toFormattedDateString() }}
</td>
<td>
<div class="d-flex">
<form method="POST"
action="{{ route('cms.consultation.show', ['uuid' => $consultation->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.consultation.delete', ['uuid' => $consultation->uuid]) }}"
id="deleteForm_{{ $consultation->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">
{{-- {{ $consultation->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>Consultation 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-consultation', 'resources/assets/sass/app.scss') }} --}}
</head>
<body>
@yield('content')
{{-- Vite JS --}}
{{-- {{ module_vite('build-consultation', 'resources/assets/js/app.js') }} --}}
</body>

View File

@@ -0,0 +1,81 @@
@extends('admin::layouts.master')
@section('title')
Consultation Message
@endsection
@section('breadcrumb')
@php
$breadcrumbData = [
[
'title' => 'Consultation Message',
'link' => 'null',
],
[
'title' => 'Dashboard',
'link' => route('dashboard'),
],
[
'title' => 'Consultation 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">Consultation Message</h4>
</div>
</div>
<div class="card">
<div class="card-header">
<h5> Consultated By {{ $consultation->name ?? 'N/A' }}</h5>
</div>
<div class="modal-body">
<table class="table">
<tbody>
<tr>
<th>Name:</th>
<td>{{ $consultation->name ?? 'N/A' }}</td>
</tr>
<tr>
<th>Email:</th>
<td>{{ $consultation->email ?? 'N/A' }}</td>
</tr>
<tr>
<th>Contact No.:</th>
<td>{{ $consultation->contact_no ?? 'N/A' }}</td>
</tr>
<tr>
<th>Age Group:</th>
<td>{{ $consultation->ageGroupOption() ?? 'N/A' }}</td>
</tr>
<tr>
<th>Procedure of Interest:</th>
<td>{{ $consultation->procedureOfInterestOption() ?? 'N/A' }}</td>
</tr>
<tr>
<th>Subject:</th>
<td>{{ $consultation->subject ?? 'N/A' }}</td>
</tr>
<tr>
<th>Message:</th>
<td>{{ $consultation->message ?? 'N/A' }}</td>
</tr>
</tbody>
</table>
</div>
<div class="card-footer">
<a href="{{ route('cms.consultation.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('consultation', fn (Request $request) => $request->user())->name('consultation');
});

View File

@@ -0,0 +1,41 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Consultation\app\Http\Controllers\ConsultationController;
/*
|--------------------------------------------------------------------------
| 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' => 'consultation.',
'controller' => 'ConsultationController',
],
function () {
Route::get('consultation', 'index')->name('index');
Route::post('consultation/{uuid}', 'show')->name('show');
Route::delete('consultation/{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-consultation',
emptyOutDir: true,
manifest: true,
},
plugins: [
laravel({
publicDirectory: '../../public',
buildDirectory: 'build-consultation',
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',
//];