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;
}
}
}