Closed dotmarn closed 1 year ago
I solved this by using using the joins instead of relationship.
Can you tell me exactly how you solved it? That's exactly what I'm trying to do. My deals table has a morphToMany relationship with my contacts table. I am trying to combine the contact name and surname, but I am getting an error. This process shouldn't be this difficult.
@emresasi I used leftJoin for the tables involved instead of using relationship and the search didn't break.
@dotmarn I understand that that process will not work for me because a deal has more than one contact, so I want to show your transaction collectively in that column without using lefjoin
Column::raw('CONCAT(users.name," ",users.surname) AS userName')
->label(__('User'))
->defaultSort('asc')
->filterable(),
You should be able to solve it like this :) My process only gives count in this way, so I can't solve it anyway. I haven't found a solution for days.
Column::name('contacts.name,surname')
->label(__('Contacts'))
->view('components.datatable.deal_contacts')
->filterable(),
In this process, the name and surname are combined in this way.
I convert it to this shape by using str in view.
<div>
<ul style="list-style: none">
@forelse(explode(',',$value) as $contact)
@if($contact)
<li><span class="badge badge-primary"
>{{\Illuminate\Support\Str::headline(\Illuminate\Support\Str::studly($contact))}}</span></li>
@endif
@empty
-
@endforelse
</ul>
</div>
But I continue to research in case there is an easier way :)
I'll put it here in case it might be useful to someone else :)
public function builder() { return EmployeeDetail::query()->with('user')->where('company_id', 1); }
` public function columns() { return [ Column::name('user.username') ->defaultSort('asc') ->searchable() ->label('Staff ID')->unwrap(),
It gives the error below