Haven't got time to go into this now, but consider this tinker session. It might give you an idea
>>> $u=User::find(1)
[!] Aliasing 'User' to 'App\User' for this Tinker session.
=> App\User {#786
id: 1,
member_id: 17,
email: "[email protected]",
loginToken: "8hTSYvBQkXNe0gHS3nuYFn1Ji",
name: "Yvonne Reid",
created_at: "2018-01-15 21:59:45",
updated_at: "2018-01-15 21:59:45",
}
>>> ${'u'}
=> App\User {#786
id: 1,
member_id: 17,
email: "[email protected]",
loginToken: "8hTSYvBQkXNe0gHS3nuYFn1Ji",
name: "Yvonne Reid",
created_at: "2018-01-15 21:59:45",
updated_at: "2018-01-15 21:59:45",
}
>>> ${'u'}->{'name'}
=> "Yvonne Reid"
>>> ${'u'}->{'member'}->{'surname'}
=> "Reid"
if your placeholders in the template were like "surgery.surgeon.lastname" then you could explode it into its parts and insert into the variable.
$parts = explode('.' , 'surgery.surgeon.lastname');
$data = ${$parts[0]}->{$parts[1]}->{$parts[2]};
I'm sure this can be refactored
anyway, it might help