You might be able to do this with Sushi but it won't be very efficient. https://github.com/calebporzio/sushi
My suggestion is to not follow this line of thought. Query the external system outside of eloquent and merge the results.
Hej,
I do have a hasOne relation like this
public function employee(): HasOne
{
return $this->hasOne(
related: Employee::class,
foreignKey: 'username',
localKey: 'username',
);
}
Problem is: The "Employee" class is extern (like in an external DB, I do have only read access). Some Usernames are written in lowercase, some are mixed and I do not know when applies what.
So, back in the days, I would make a lowercase compare on both sides and the problem would have fixed with that. But how do I do this with eloquents relation classes?
Simply setting the "foreignKey" to "lower('username')" surely is not working. How to fix this?
Please or to participate in this conversation.