Attempt to read property "model" on null.
I have a table that has a column "Briefcase" to show if the record (Business) belongs to a Briefcase.
I'm implementing "->tooltip" to show to which User's Briefcase the Business belongs to.
The above "tooltip" code fails when one business is not allocated to any Briefcase,
I get:
Please, any ideas how can I fix it?
Thanks.
6 Replies
Use the nullsafe operator
$record->briefcase?->user->name
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
Nice, thank you for your help... Works.
I have also tried your solution, also works. Now, I think this is better long time/maintenance. Also the "data_get" function accepts a default value which is nice and helpful. Thank you.
yep
You can pass a default via
?? 'default'
$record->briefcase?->user->name ?? 'default'
Embrace modern PHP 😅Honestly, this tool/chat and of curse FilamentPHP is pushing me to learn more and more... thanks.