⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.19
Server IP:
178.33.27.10
Server:
Linux cpanel.dev-unit.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
Server Software:
Apache/2.4.57 (Unix) OpenSSL/1.0.2k-fips
PHP Version:
8.2.11
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
id
/
hospital.dev-unit.com
/
app
/
Livewire
/
View File Name :
DoctorAppointmentRelationTable.php
<?php namespace App\Livewire; use App\Filament\HospitalAdmin\Clusters\Doctors\Resources\DoctorResource; use App\Filament\HospitalAdmin\Clusters\Patients\Resources\PatientResource; use App\Models\Appointment; use App\Models\Doctor; use App\Models\User; use Filament\Forms\Concerns\InteractsWithForms; use Filament\Forms\Contracts\HasForms; use Filament\Support\Enums\FontWeight; use Filament\Tables\Columns\SpatieMediaLibraryImageColumn; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Concerns\InteractsWithTable; use Filament\Tables\Contracts\HasTable; use Filament\Tables\Table; use Illuminate\Support\Facades\Route; use Livewire\Component; class DoctorAppointmentRelationTable extends Component implements HasForms, HasTable { use InteractsWithForms; use InteractsWithTable; public $record; public function GetRecord() { $id = Route::current()->parameter('record'); $appointments = Doctor::with('appointments')->where('id', $id)->get(); foreach ($appointments as $item) { $this->record = $item->cases; } $appointment_ids = $this->record->pluck('doctor_id')->toArray(); $data = Appointment::with('doctor.doctorUser')->whereIn('doctor_id', $appointment_ids)->orderByDesc('id'); // dd($data); return $data; } public function table(Table $table): Table { return $table ->query(self::GetRecord()) ->paginated([10, 25, 50]) ->columns([ SpatieMediaLibraryImageColumn::make('patient.patientUser.profile') ->label(__('messages.case.patient')) ->circular() ->defaultImageUrl(function ($record) { if (! $record->patient->patientUser->hasMedia(User::COLLECTION_PROFILE_PICTURES)) { return getUserImageInitial($record->id, $record->patient->patientUser->first_name); } }) ->url(fn ($record) => PatientResource::getUrl('view', ['record' => $record->patient->id])) ->collection('profile') ->width(50)->height(50), TextColumn::make('patient.patientUser.full_name') ->label('') ->formatStateUsing(fn ($record) => '<a href="'.PatientResource::getUrl('view', ['record' => $record->patient->id]).'" class="hoverLink">'.$record->patient->patientUser->full_name.'</a>') ->html() ->color('primary') ->weight(FontWeight::SemiBold) ->description(fn ($record) => $record->patient->patientUser->email ?? __('messages.common.n/a')) ->searchable(['first_name', 'last_name']), SpatieMediaLibraryImageColumn::make('doctor.doctorUser.profile') ->label(__('messages.role.doctor')) ->circular() ->defaultImageUrl(function ($record) { if (! $record->doctor->user->hasMedia(User::COLLECTION_PROFILE_PICTURES)) { return getUserImageInitial($record->id, $record->doctor->user->full_name); } }) ->url(fn ($record) => DoctorResource::getUrl('view', ['record' => $record->doctor->id])) ->collection('profile') ->width(50)->height(50), TextColumn::make('doctor.doctorUser.full_name') ->label('') ->color('primary') ->weight(FontWeight::SemiBold) ->description(fn ($record) => $record->doctor->doctorUser->email ?? __('messages.common.n/a')) ->formatStateUsing(fn ($record) => '<a href="'.DoctorResource::getUrl('view', ['record' => $record->doctor->id]).'" class="hoverLink">'.$record->doctor->doctorUser->full_name.'</a>') ->html() ->searchable(['first_name', 'last_name']), TextColumn::make('doctor.department.title') ->label(__('messages.appointment.department_name')), TextColumn::make('opd_date') ->label(__('messages.appointment.opd_date')) ->searchable() ->getStateUsing(function ($record) { $date = \Carbon\Carbon::parse($record->opd_date)->translatedFormat('jS M, Y'); $time = \Carbon\Carbon::parse($record->opd_date)->translatedFormat('g:i A'); return "<div class='text-center'><span>{$time}</span><br><span class='text-sm'>{$date}</span></div>"; }) ->html() ->sortable(), ]) ->filters([ // ]) ->bulkActions([ // Tables\Actions\BulkActionGroup::make([ // Tables\Actions\DeleteBulkAction::make(), // ]), ]) ->emptyStateHeading(__('messages.common.no_data_found')); } public function render() { return view('livewire.doctor-appointment-relation-table'); } }