Been struggling with how to do this the most optimized way possible...
I have two models: Catalog and Application.
Catalog has a field called name.
Application has a field called name.
Both have a relationship with each other.
I am struggling to find a way to create a function i could use across my Laravel application which i would pass application.id to it and it would return a $app->name value based on the following logic:
- if
$application->nameexists, use this value as the$app->namefor the$applicationobject - otherwise, get the
$catalog->namevalue and use it as the$app->name
Note that I would like to create a component @application() where i can simply pass the $application->id and build the display logic (theming/styling) into it.
Since i display this $app->name in many places, i would like to make it as lightweight as possible to avoid unnecessary queries.
I hope this makes sense! There are probably so many ways to go with it, i am lost at figuring out the way way to do this :(
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire