MedicOneSystems / livewire-datatables

Advanced datatables using Laravel, Livewire, Tailwind CSS and Alpine JS
https://livewire-datatables.com/
MIT License
1.19k stars 258 forks source link

Duplicate User I'd Names #518

Closed abbasmashaddy72 closed 2 months ago

abbasmashaddy72 commented 1 year ago

Example: I have Users Table. There are Patients, Doctors and all other users in it based on role user table.

I have an Appointment Table. Where patient_id, doctor_id these forign_ids belongs to User Table.

When I create a Livewire Datatable I am having issue Retrieving the Data When It is duplication the username on Doctor Name if Patient Name is given First.

If I Check the Direct Query Data.

It is working perfectly.

Don't Know Whet the Issue is, Please Check.

LiveWire Table Code: `public $model = OpdPatient::class; public $exportable = true;

public function builder()
{
    return OpdPatient::query();
}

public function columns()
{
    return [
        Column::checkbox()
            ->label('Checkbox'),

        Column::index($this)
            ->unsortable(),

        Column::name('patient.name')
            ->searchable()
            ->label('Patient Name')
            ->filterable(),

        DateColumn::name('date')
            ->searchable()
            ->filterable(),

        TimeColumn::name('time')
            ->searchable()
            ->filterable(),

        Column::name('doctor.name')
            ->searchable()
            ->label('Doctor Name')
            ->filterable(),

        Column::name('description')
            ->searchable()
            ->truncate(50)
            ->filterable(),

        Column::callback(['id'], function ($id) {
            return view('backend.pages.opd-patients.actions', ['id' => $id]);
        })->excludeFromExport()->unsortable()->label('Action'),
    ];
}`

Model Code: `protected $fillable = [ 'patient_id', 'doctor_id', 'date', 'time', 'description', ];

public function patient()
{
    return $this->belongsTo(User::class, 'patient_id');
}

public function doctor()
{
    return $this->belongsTo(User::class, 'doctor_id');
}`

Table Screen Shot: image

Edit Screen Shot: image

Please Help Me Out...

abbasmashaddy72 commented 1 year ago

@tomshaw @andruu

Can You Please Look into it

abbasmashaddy72 commented 2 months ago

Closed as using Filament