Combining 2 fields in one table's column
in my company table i have this code
this show only the name, the relation between company and customer is
i need to concat customer.name and customers.last_name
tried different approach but without success
20 Replies
You can use formatStateUsing
i found this examples but doesn't works..
Check your relationship maybe
Another way:
in my customer model
in my company model
in my companyResource table definition
this show the name of the customers (one or more)
this one show company name (not the customer name)
this show nothing
this show company name
this gives me this error
the pivot table in the db
Well you put consumer instead of customer.
yes yes, a typo but the errror remain
Don't you need pass the company id and user id in the customers()?
idk, all the examples above are from a search on google
if i use this
the error is strange
i'm using App\Models\Customer not App\Models\Company
You use Customer modal but the customers relationship is inside company modal.
yes and i'm in the CompanyResource
Because you don't have customers inside your customrer model.
Alternative solution to make your life easier, add this in your migration
and in your table list just call the
Maybe show your database schema
Perhaps I am not understanding. In the display of the table with all the companies, I need to show the customer associated with the company. The customer model is present in the company, and vice versa. The relationship is present in both models.
this is the pivot table
companies and customers table are regular tables
Yes, the virtualAs is not a bad solution, but if there is an alternative, I would like to know it.
done with virtual field
I mean the customer and company table too
customer
companies
Id you change the Customer model into company still not work ?
I will look into tonight, thanks for the help