mardi 22 décembre 2020

Laravel display object from foreach

i want to echo ouptut from controller When i dump this object i get all data like i want, but how to echo that I want to display this data like this

Here is my controller

$pkm = DB::table('magacin_pkms')->select(
    'magacin_pkms.status',
    'magacin_pkms.izdao_to',
    'users.name as izdaoFirstName',
    'users.lastname as izdaoLastName',
    'magacin_pkms.vrednost',
    'magacin_pkms.izdao_by',
    'magacin_pkms.izdao_at'
)
    ->join('users', 'id_user', 'izdao_to')
    ->where('magacin_pkms.status', 2)
    ->orderBy('izdao_to')
    ->get();

$driverIDs = array_unique($pkm->pluck('izdao_to')->toArray());

foreach ($driverIDs as $id) {
    $obj  = new StdClass;
    $name = $pkm->where('izdao_to', $id)->first()->izdaoFirstName;
    $lastname = $pkm->where('izdao_to', $id)->first()->izdaoLastName;
    $cnt = $pkm->where('izdao_to', $id)->count();
    $total = $pkm->where('izdao_to', $id)->sum('vrednost');
    $admin = $pkm->where('izdao_to', $id)->first()->izdao_by;
    $izdato = $pkm->where('izdao_to', $id)->first()->izdao_at;
  
    $obj->name = $name;
    $obj->lastname = $lastname;
    $obj->cnt = $cnt;
    $obj->total = $total;
    $obj->admin = $admin;
    $obj->izdato = $izdato;
    dump($obj);
}

this is my view

@foreach ($obj as $items)
    <tr>
        <td></td>
        <td> </td>
        <td></td>
        <td></td>
        <td> $</td>
        <td></td>
        <td></td>
@endforeach


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/38syxAf
via IFTTT

Aucun commentaire:

Enregistrer un commentaire