I want to pass data to Laravel view and do not understand certain parameters within the with()
method. What parameter name
refer to?
return view('pages.about')->with('name', $name);
what parameter 'name' refer to
Name is the alias you give to the variable $name
which you can access in your view.
e.g
$name= 'John Doe';
return view('pages.about')->with('myName', $name);
So now you can access $myName
in about
view
From the docs it says:
As an alternative to passing a complete array of data to the view helper function, you may use the with method to add individual pieces of data to the view
Ref: Docs
UPDATE AFTER COMMENTS: In your case you should use with as below:
return view ('pages.absensi')->with('Rfidabs' => $Rfidabs);
then in your abseni
view you can loop through the array as below:
foreach ($Rfidabs as $item)
<tbody>
<td>{{$item->id}}</td>
<td>{{$item->Name}}</td>
<td>{{$item->Kelas}}</td>
</tbody>
endforeach