I am new to php laravel. I am building a small app which displays the user table from the DB but before sending it to the view, i want to include a custom value from another function.
The accounts table fetches the list of account from MySQL and i want to include a custom function called Status which i get from an API.
The code is:
public function accounts()
{
$accounts = DB::table('accounts')
->where('profile_id', '=', Auth::id())
->get();
foreach ($accounts as $account) {
$account->status = getStatus($account->accno);
}
$data = compact('accounts');
return view::make('transactions', ['accounts' => $data]);
}
// View
@foreach ($accounts as $account)
<tr>
<td></td>
<td></td>
<td></td>
</tr>
@endforeach
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2BOVOxq
via IFTTT
Aucun commentaire:
Enregistrer un commentaire