You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to filter my cases model by patient, in which both have their own filters respectively. In my patient filter, I have the following filter I'd like to re-use if possible:
I'm trying to access this filter from within my CaseEntityFilter class so I can pass something like patient_name as a filter on the case and return cases matching the patient name.
Here's what I've tried for the filter on cases, but to no luck:
classCaseEntityFilterextendsModelFilter
{
// Cant seem to get this to point to the method on the actual filterpublic$relations = [
'patient' => [
'name',
'firstName',
'patient_name'
]
];
// Produces 'invalid column' errorpublicfunctionpatientName($name)
{
return$this->related('patient', 'name', $name);
}
My database (SQL Server) throws an error about the column name not existing (which it rightfully doesn't). I can't seem to figure out how to execute the name() method on my patient's filter instead of just querying for the column 'name'.
I'm new to Laravel so is there something I'm missing or would this be considered a feature request?
Thank you for the excellent plugin by the way! :)
The text was updated successfully, but these errors were encountered:
They way you have this set up, if you pass a name parameter to your CaseEntityFilter it will automatically forward that to the name method on PatientFilter because name is present in your $relations['patient'] array. That array is also setup to forward a firstName parameter to PatientFilter::firstName() (if it exists) and patient_name to PatientFilter::patientName() (if it exists) without having to define any methods on CaseEntityFilter.
If you want to use a patient_name parameter to call a patientName() method on your CaseEntityFilter that will call the name() on PatientFilter then you can do it like:
classCaseEntityFilterextendsModelFilter
{
// Cant seem to get this to point to the method on the actual filterpublic$relations = [
'patient' => [
'name',
'firstName'
]
];
publicfunctionpatientName($name)
{
return$this->related('patient', function($query) use ($name) {
// $query here is an instance of the `patient` relation's query builderreturn$query->filter(['name' => $name]);
});
}
I'm trying to filter my
cases
model bypatient
, in which both have their own filters respectively. In mypatient
filter, I have the following filter I'd like to re-use if possible:I'm trying to access this filter from within my
CaseEntityFilter
class so I can pass something likepatient_name
as a filter on the case and return cases matching the patient name.Here's what I've tried for the filter on cases, but to no luck:
My database (SQL Server) throws an error about the column
name
not existing (which it rightfully doesn't). I can't seem to figure out how to execute the name() method on my patient's filter instead of just querying for the column 'name'.I'm new to Laravel so is there something I'm missing or would this be considered a feature request?
Thank you for the excellent plugin by the way! :)
The text was updated successfully, but these errors were encountered: