How to get content field of relative model when selection value was selected ? #55
Answered
by
Z3d0X
sergeynilov
asked this question in
Q&A
-
In filament-fabricator "^1.1 I made a possibility to select Page from selection input like :
But in block blade.php template file if I insert {{ $page_content_id }} var I got only integer code, but how can I get content field of relative model? Has it some hooks ? Thank you! |
Beta Was this translation helpful? Give feedback.
Answered by
Z3d0X
Mar 28, 2023
Replies: 1 comment
-
You could use public static function mutateData(array $data): array
{
$pageContent = PageContent::find($data['page_content_id'] ?? null);
return [...$data, 'page_content' => $pageContent];
} docs: https://filamentphp.com/plugins/fabricator#mutate-data |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
sergeynilov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could use
mutateData
to retrieve the model.docs: https://filamentphp.com/plugins/fabricator#mutate-data