I have 5 joining tables. Out of those 5 tables some tables some have the same column names.
public function index() {
$Users = User::leftJoin('employee', 'users.user_employee_id', 'employee.EMP_ID')
->leftJoin('account_executive', 'account_executive.EMP_ID', '=', 'employee.EMP_ID')
->leftJoin('independent_sales_rep', 'independent_sales_rep.EMP_ID', '=', 'employee.EMP_ID')
->leftJoin('internal_sales_agent', 'internal_sales_agent.EMP_ID', '=', 'employee.EMP_ID'),
->whereNotNull('users.user_employee_id')
->get();
return View('adminlte::equipment.salesreps', ['Users' => $Users]);
}
For example, account.executive, independent_sales_rep, and internal_sales_agent all three have EMP_ID
.
How can I retrieve all data besides going column by column writing what I need?
I can use
->select('account_executive.EMP_ID as AE_EMP_ID',
'independent_sales_rep.EMP_ID as IND_EMP_ID',
'internal_sales_agent.EMP_ID as INT_EMP_ID)
but it becomes a real drag when you have hundreds of rows you need to retrieve data. I was hoping to use something like:
@foreach($Users as $User)
<p> </p>
@endforeach
Obviously that wouldn't work but is there something similar that would work for lots of columns?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire