0

How to use compact function in php 7.3.9

15th Mar 2022, 10:56 AM
Muhammad Arsalan
Muhammad Arsalan - avatar
13 Answers
+ 3
Is it possible to analyse what <$users> variable content is? just in case ... You wrote "Compact" there, I take it was a typo? cause PHP is case sensitive (you know). Also view('showAttendance ... had a single quote in the beginning. Was that also a typo perhaps?
15th Mar 2022, 12:38 PM
Ipang
+ 2
Yes, I was asking you, is there a way to preview the content of <$requests> variable. This information is necessary. Since you changed the variable from <$users> to <$requests>, is it perhaps the cause why <$users> is not recognized in the view? just a guess ...
15th Mar 2022, 12:51 PM
Ipang
+ 1
Explain "not working", like you get an error message, or what?
15th Mar 2022, 11:37 AM
Ipang
+ 1
Is <$requests> variable totally unrecognized in there? Can you perhaps just dump its content to see what's inside? I'm not sure what's wrong ...
15th Mar 2022, 1:12 PM
Ipang
0
I am working in laravel 5.8 its not working here
15th Mar 2022, 11:35 AM
Muhammad Arsalan
Muhammad Arsalan - avatar
0
I want to fetch data from database in view table i use conpact function in controller and foreach loop in view file when i used variable in foreach loop in view file it gives me undefined variable error
15th Mar 2022, 11:42 AM
Muhammad Arsalan
Muhammad Arsalan - avatar
0
Here is my controller Public function index(){ $users=DB::table('requests')->get(); return view('showAttendance, Compact ('users')); } And my view is @foreach($users as $user) <td>{{$user->date}}</td> <td>{{$user->name}}</td>
15th Mar 2022, 11:49 AM
Muhammad Arsalan
Muhammad Arsalan - avatar
0
$requests=DB::table('requests')->get(); this is my variable
15th Mar 2022, 12:44 PM
Muhammad Arsalan
Muhammad Arsalan - avatar
0
return view('showAttendanece', compact('requests')); that is my return
15th Mar 2022, 12:46 PM
Muhammad Arsalan
Muhammad Arsalan - avatar
0
This is my showAttendance view want to fetch data from database dynamically and show in table @foreach($requests as $user) <td>{{$user->date}}</td> <td>{{$user->name}}</td>
15th Mar 2022, 12:59 PM
Muhammad Arsalan
Muhammad Arsalan - avatar
0
Problem is in this $requests variable which i decleared in my controller index function
15th Mar 2022, 1:02 PM
Muhammad Arsalan
Muhammad Arsalan - avatar
0
It gives null value after dump
15th Mar 2022, 1:56 PM
Muhammad Arsalan
Muhammad Arsalan - avatar