Please help check the code to see where there is error as I am not a coder but just using the application from another developer
<div class="bs-example widget-shadow table-responsive" data-example-id="hoverable-table">
<table class="table table-hover">
<thead>
<tr>
<th>ID</th>
<th>Client name</th>
<th>Amount</th>
<th>Payment mode</th>
<th>Receiver's email</th>
<th>Status</th>
<th>Date created</th>
<th>Option</th>
</tr>
</thead>
<tbody>
#foreach($withdrawals as $deposit)
<tr>
<th scope="row">{{$deposit->id}}</th>
<td>{{$deposit->duser->name}}</td>
<td>{{$deposit->amount}}</td>
<td>{{$deposit->payment_mode}}</td>
<td>{{$deposit->duser->email}}</td>
<td>{{$deposit->status}}</td>
<td>{{$deposit->created_at}}</td>
<td> <a class="btn btn-default" href="{{ url('dashboard/pwithdrawal') }}/{{$deposit->id}}">Process</a></td>
</tr>
#endforeach
The problem is in {{$deposit->duser->name}} and {$deposit->duser->email}}. Every withdrawal must have a valid user ID. This user ID will be matched against user table and the name and email of that user will be showed in blade.
What is happening is this, one or more $deposit has invalid user ID. So, the blade is trying to search in the table to get the name and email. But it is not finding it. So essentially it is trying to get the name value of a null object and crashing the app.
You can try to check if the duser have a null value by using following code,
#foreach($withdrawals as $deposit)
#if(!is_null($deposit->duser))
<tr>
<th scope="row">{{$deposit->id}}</th>
<td>{{$deposit->duser->name}}</td>
<td>{{$deposit->amount}}</td>
<td>{{$deposit->payment_mode}}</td>
<td>{{$deposit->duser->email}}</td>
<td>{{$deposit->status}}</td>
<td>{{$deposit->created_at}}</td>
<td> <a class="btn btn-default" href="{{ url('dashboard/pwithdrawal') }}/{{$deposit->id}}">Process</a></td>
</tr>
#endif
#endforeach
Related
In this image this table is based on my databse "Employee" table. there is 2 part. 1st part is from "#" column to "employee type" column. 2nd part is "Leave Type" Column. This column infromation will come from "LeaveType" Table. No I want to create different type leavetype for 1 employee. It mean I want to create subrow for each parent row in this column. But I can't
here is my incomplete table code in blade file.
<table class="table table-bordered mb-0" id="myTable">
<thead class="bg-orange">
<tr class="text-light">
<th >#</th>
<th >Employee Name</th>
<th >Employee Id</th>
<th >Employee Type</th>
<th >Leave Type</th>
<th >Entitled</th>
<th >Used Leave</th>
<th >Balance</th>
</tr>
</thead>
<tbody>
#foreach($users as $user)
<tr>
<th scope="row">{{$loop->iteration}}</th>
<td>
{{$user->name}} <br>
#foreach($designations as $designation)
#if($designation->id === $user->designationId)
{{$designation->designationName}}
<br>
#endif
#endforeach
#foreach($departments as $department)
#if($department->id === $user->departmentId)
{{$department->departmentName}}
#endif
#endforeach
</td>
<td>{{$user->employeeId}}</td>
#foreach($designations as $designation)
#if($designation->id === $user->designationId)
<td>{{$designation->attendanceType}}</td>
<br>
#endif
#endforeach
<td>
</td>
</tr>
#endforeach
</tbody>
</table>
I'm trying to figure how to iterate through this table which shows monthly records provided by different facilities within any one month.
As it is, every record from each facility has a month associated with it, but I want to make it so that there only one month record, followed by the next month displaying in the same way and so on.
I've been told to use an if statement to iterate through the month column to determine the number of rows one month record should cover, but I'm confused regarding the syntax, any suggestions?
This is the table code I'm working with atm:
<table id="table2" class="table table-bordered table-striped table-condensed table-hover display" >
{{-- Beginning of headers --}}
<thead>
<tr class="text-center">
<th>Month</th>
<th>Grade</th>
<th colspan="3">Volume (m<sup>3</sup>)</th>
</tr>
<tr class="text-center">
<th></th>
<th></th>
<th>Received</th>
<th>Milled</th>
<th>Balance</th>
</tr>
</thead>
{{-- End of headers --}}
{{-- Beginning of data --}}
#foreach ($grades1 as $g)
<tbody class="text-center">
<tr class="text-center">
<td rowspan="100">{{$g->yr_mm}}</td>
<tr>
<td>{{$g->grade}}</td>
<td>{{$g->vol_received}}</td>
<td>{{$g->vol_milled}}</td>
<td>{{$g->vol_balance}}</td>
</tr>
</tr>
</tbody>
#endforeach
{{-- End of data --}}
</table>
Trying to make one html table where is showing what login users choose.
One login auth users and one form data.
Here data is showing on page but scramled in table.
Homedata is showing twice.
Here is my index page where im trying to do:
<table class="table" id="users-info">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First Name</th>
<th scope="col">Last Name</th>
<th scope="col">Naional Number</th>
<th scope="col">Device</th>
<th scope="col">Reimbursment</th>
<th scope="col">Warranty</th>
</tr>
</thead>
<tbody>
#if(count($users) > 0)
#foreach($users as $user)
<tr>
<th scope="row">{{ $user->id }}</th>
<td>{{ $user->firstname }}</td>
<td>{{ $user->lastname }}</td>
<td>{{ $user->phone }}
#foreach($homedata as $homedatas)
<td>{{$homedatas->device}}</td>
<td>{{$homedatas->reimburse_Pension}}</td>
<td>{{$homedatas->bonus_remainder}}</td>
#endforeach
</td>
</tr>
#endforeach
#endif
</tbody>
</table>
Please help.
if there is another way please feel free suggest.
Hey everyone who share the same problem.
I add in second foreach ->slice(0, 1) and that foreach just going once, that automaticaly means no duplicate data :)
Hello i am a laravel beginner , when i do foreach its shows double of all single items what should i do with it code and ss are below
Brower image
code
<div >
<h1 style="text-align: center">Lists of Outlets</h1>
#foreach($outlets as $outlet)
<table class="table table-striped">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
<td>john#example.com</td>
</tr>
</tbody>
</table>
#endforeach
</div>
The issue is, you have put the entire table inside the loop, which is wrong. You have to only put the tr inside the loop.
Try this:
#foreach($outlets as $outlet)
<tr>
<td>John</td>
<td>Doe</td>
<td>john#example.com</td>
</tr>
#endforeach
and one more thing, you are also using the static content inside the loop instead of using the loop variable value. So instead of:
<td>john#example.com</td>
it is something like:
<td>{{ $outlet['name'] }}</td> <!-- where name is the index in outlet array -->
#foreach should be inside <tbody> and instead of hard-coded content, you should be using $outlet variable to get firstname, lastname and Email:
<div>
<h1 style="text-align: center">Lists of Outlets</h1>
<table class="table table-striped">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
#foreach($outlets as $outlet)
<tr>
<td>John</td>
<td>Doe</td>
<td>john#example.com</td>
</tr>
#endforeach
</tbody>
</table>
</div>
I have a table display and each row contains a button. With this button l have to pass the id to the controller where using this Admin can view user details one by one.
<table id="example2" class="table table-bordered table-hover" style="text-align: center">
<thead>
<tr>
<th>Applicant ID</th>
<th>Full name</th>
<th>Position applied</th>
<th>Date & time applied</th>
<th>View CV</th>
</tr>
</thead>
<tbody>
#foreach ($jobapplied as $row)
<tr>
<td>{{$row->app_id}}</td>
<td>{{$row->fullname}}</td>
<td>{{$row->position}}</td>
<td>{{$row->created_at}}</td>
<td>
<button type="submit" class="btn btn-
default" name="viewcv"> View</button> <br>
<br>
</td>
</tr>
#endforeach
</tbody>
</table>
Please check the code , hope it helps:
<table id="example2" class="table table-bordered table-hover" style="text-align: center">
<thead>
<tr>
<th>Applicant ID</th>
<th>Full name</th>
<th>Position applied</th>
<th>Date & time applied</th>
<th>View CV</th>
</tr>
</thead>
<tbody>
#foreach ($jobapplied as $row)
<tr>
<td>{{$row->app_id}}</td>
<td>{{$row->fullname}}</td>
<td>{{$row->position}}</td>
<td>{{$row->created_at}}</td>
<td>CV</td>
</tr>
#endforeach
</tbody>
</table>
Assuming you want to pass the field "id" or change it according to your requirement.
If you want to link to a show view, try something like this:
#foreach ($jobapplied as $row)
<tr>
<td>{{$row->app_id}}</td>
<td>{{$row->fullname}}</td>
<td>{{$row->position}}</td>
<td>{{$row->created_at}}</td>
<td>
<a href="{{action('JobController#show', $row->id)}}" class="btn btn-default">View</button>
</td>
</tr>
#endforeach
This will create a link to a view, where you can show the data.
In your controller JobController, you must create a function that receives the data:
public function show(Request $request, $id) {
...
}
Just pass the id of the record to controller function and get the details from database.
<td>
View <br>
</td>