Search code examples
phplaravelmodellaravel-novalaravel-filament

How can i get data from another model and show it in another resource using Laravel Filament


I want to get a values of a column/filed of a table/model in Laravel Filament and showing it in another resource (another Model) that they models don't have any relationships between together.

For example i have a title column in my model and i want to show it values in another resource section of Laravel Filament package.

TextColumn::make('title')->label('Category'),

So in this code snippet i want to get info from another model like CategoryBlog (i mean my resource/model is Blog and my needed data is in Categoryblog model and they don't have relationship between together).

So how can i do this??

TextColumn::make({{the code that get data from another model}})->label('Category'),

Can i do like above code?? where code?? what code?

TextColumn::make('title')->value({{or in this place???}})->label('Category'),

Or something like below code!

CustomeCode::method->method

I don't know please help me!


Solution

  • You can get the relationship data with 'relationshipNameInModel.columnOrAccessorName' like TextColumn::make('category.title')->label('Category') in Filament.