This is my blade view:
#extends('emails.newlayout')
#section('title', 'Reminder')
#section('content')
<?php $total = 0; ?>
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
#foreach ($sallary as $emp)
<tr>
<td>{{ $emp->employee['name'] }}</td>
<td>{{ $emp['value'] }}</td>
<?php $total += $emp['value']; ?>
</tr>
#endforeach
</tbody>
</table>
<p>Total: US${{ $total }}</p>
#stop
And this is within the header of my newlayout.blade.php:
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
Works just fine on my browser when I open it as html, but when I render it on laravel it just doesn't load the bootstrap css at all (loads everything else). I wonder what am I doing wrong?
OUTPUT
<table class="m_-7473167048951624218table m_-7473167048951624218table-striped">
<thead>
<tr>
<th>Name</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Test 2</td>
<td>1,093.55</td>
</tr>
<tr>
<td>Test 3</td>
<td>1,090.33</td>
</tr>
</tbody>
</table>
Solved it
Embarrassing, but turns out it's because of e-mail. Every style should be inline css on an email, otherwise it doesn't render well according to a plethora of documentation about styling mails online.
Related
Jquery datatable plugin is not working when it has data that selected from database by date. But it's working if there is no data in table. Here some code
Select all data from database table in controller :
$inbound['inbound'] = DB::table('REPORT_INBOUND')
->where('regdate', '=', date('Y-m-d', strtotime("2019-05-21")))
->get();
return view('/traffic', $inbound, $outbound);
And i did copy paste that necessary scripts for example :
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<table id="ahhhaa" width="90%" class="table table-striped table-bordered table-hover display">
<thead class="thead-light">
<tr>
<th>ID</th>
<th>RegDate</th>
<th>HPMN Code</th>
<th>Country</th>
<th>HPMN Name</th>
</tr>
</head>
<tbody>
#foreach($inbound as $value)
<tr class="table table-hover">
<td>{{ $value->id }}</td>
<td>{{ $value->regdate }}</td>
<td>{{ $value->hpmn_code }}</td>
<td>{{ $value->country }}</td>
<td>{{ $value->hpmn_name }}</td>
#endforeach
</tbody>
</table>
$(document).ready(function () {
$('#ahhhaa').DataTable()
});
Is there any error ?
Maybe because u did not close your thead.
Fix this and comment if not solved .
<table id="ahhhaa" width="90%" class="table table-striped table-bordered table-hover
display">
<thead class="thead-light">
<tr>
<th>ID</th>
<th>RegDate</th>
<th>HPMN Code</th>
<th>Country</th>
<th>HPMN Name</th>
</tr>
</thead><!-- Add this Line -->
<tbody>
loop...
</tbody>
Hope this works !
return your view page with data:
return view('folder/file_name')->with($inbound);
Change the id of the table.Otherwise the laravel will not identify the table as a datatable.
<table id="datatable-buttons" class="table table-responsive">
I have following html code in my document for generating PDF, but resulted PDF is not generating properly.
<table border="1" class="table table-striped">
<thead>
<th>Sr No.</th>
<th>Particulars </th>
<th>Qty </th>
<th>rate </th>
<th>Amount </th>
</thead>
<tbody>
<br><br>
#foreach($data as $row)
<tr>
<td>{{ $row['temp_invoice_id'] }}</td>
<td>{{ $row['tyre_brand']." ".$row['tyre_model'] }}</td>
<td>{{ $row['quantity'] }}</td>
<td>{{ $row['rate'] }}</td>
<td>{{ $row['total'] }}</td>
</tr>
#endforeach
</tbody>
</table>
But when the PDF is generated it shows something like this I don't know why it's not generating proper PDF can anyone have solution over this problem, or we have to apply separate css for print media?
Inside thead use tr tag it is working fine.
<thead>
<th>Sr No.</th>
<th>Particulars </th>
<th>Qty </th>
<th>rate </th>
<th>Amount </th>
</thead>
use like this,
<thead>
<tr>
<th>Sr No.</th>
<th>Particulars </th>
<th>Qty </th>
<th>rate </th>
<th>Amount </th>
</tr>
</thead>
Remove the <br><br> snippet in your <tbody> they are not valid, so the browser might ignore them but maybe the PDF generator (I don't know which one you use) might not.
Also place the <th>s inside a row (<tr>)
My code is here if you want any other section of code, i will provide also that piece of code
<div class="panel-heading ">Organization Profile</div>
<table class="table table-striped">
<thead>
<tr>
<th>Attributes</th>
<th>Values</th>
</tr>
</thead>
<tbody>
<tr>
<td>Org Name</td>
<td>{{$org->name}}</td>
</tr>
<tr>
<td>Owner Name</td>
<td>{{$org->owner}}</td>
</tr>
</tbody>
</table>
</div>
Trying to get property of non-object issue usually comes in Laravel when you are returning array but try using object in your blade file or not passing the correct object string at all.
I notice from comments that you are passing $orgs, not $org in the function.
public function create() {
return view('Admin.organizations.create',compact('orgs'));
}
Update your blade file like below:
<div class="panel-heading ">Organization Profile</div>
<table class="table table-striped">
<thead>
<tr>
<th>Attributes</th>
<th>Values</th>
</tr>
</thead>
<tbody>
<tr>
<td>Org Name</td>
<td>{{$orgs->name}}</td>
</tr>
<tr>
<td>Owner Name</td>
<td>{{$orgs->owner}}</td>
</tr>
Considering all the comments, you should probably have something like this in your controller:
public function show($id)
{
$org = Organization::find($id);
// $data = ['org', $id];
return view('Admin.organizations.show')->with(compact('org'));
}
and this is your blade view:
<div class="panel-heading ">Organization Profile</div>
#if (empty($org))
<h1>Organization is empty</h1>
#else
<table class="table table-striped">
<thead>
<tr>
<th>Attributes</th>
<th>Values</th>
</tr>
</thead>
<tbody>
<tr>
<td>Org Name</td>
<td>{{$org->name}}</td>
</tr>
<tr>
<td>Owner Name</td>
<td>{{$org->owner}}</td>
</tr>
</tbody>
</table>
#endif
</div>
Of course not knowing what is in the Organization model would keep us from knowing whether owner and name exist as properties of the model.
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>
#foreach($lastactivity as $activity)
{{ $activity }}
#endforeach
That is the for loop.
Now this is the output in the view.
{"id":2,"log_name":"index-log","description":"I visited index","subject_id":null,"subject_type":null,"causer_id":1,"causer_type":"App\\User","properties":[],"created_at":"2017-07-18 11:05:08","updated_at":"2017-07-18 11:05:08"}
How will I be able to put that in a table with all the columns and data arranged? Thank you very much.
You should use table.
<table>
<thead>
<tr>
<th>Log Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
#foreach($lastactivity as $activity)
<tr>
<td>{{$activity->log_name}}</td>
<td>{{$activity->description}}</td>
</tr>
#endforeach
</tbody>
</table>
In the same way, Add other fields as well.
You have to define your field name
{{ $activity->id }}
{{ $activity->log_name }}
etc
Like this:
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>Log Name</th>
.
.
.
<th>Updated At</th>
</tr>
</thead>
<tbody>
#foreach($lastactivity as $activity)
<tr>
<td>{{ $activity->id }}</td>
<td>{{ $activity->log_name }}</td>
.
.
.
<td>{{ $activity-> }}</td>
</tr>
#endforeach
</tbody>
</table>