chris.mccabe
Remove/change the default where clauses in relation manager
I am posting this from a discussion on another thread/message:
I have built a demo EHR system around medical records- I may not have architectured this correctly but i want to have appointments and prescriptions linked so when a patient gets prescribed something its linked to an appointment, doctor and patient. i created PrescriptionsRelationManager which:
* I want to see all the prescriptions for the patient listed in the table not just the ones tied to this appointment_id
* but when one is added through the Relation Manager that appointment_id is set
i have tried using modifyQueryUsing but i can over write the default where clauses generated
```php
])->modifyQueryUsing(function (Builder $query) {
$appointmentId = $this->ownerRecord->id;
$patientId = $this->ownerRecord->patient_id;
return $query->where(function ($query) use ($appointmentId) {
$query->where('appointment_id', $appointmentId)
->orWhereNull('appointment_id');
})->where('patient_id', $patientId);
});
still generates the Sql:
select count(*) as aggregate from "prescriptions" where "prescriptions"."appointment_id" = 1 and "prescriptions"."appointment_id" is not null and ("appointment_id" = 1 or "appointment_id" is null) and "patient_id" = 1
I want to remove the default where clauses? or is there a different way to do this?
2 replies
Access filter options in resource static method
I have dynamic columns for a json field meaning i have json records stored in a db and the columns to display the values from the json record are stored as json paths in another table.
How do i get the value of the table filters in the static table method?
This prints an empty array?
2 replies