Laravel a tag not visible - php

I've got this code:
<div class="container col-md-6 col-md-offset-3">
<div class="well well bs-component">
<table class="table">
<thead>
<tr>
<th>Logo</th>
<th>Bedrijfsnaam</th>
<th>Plaats</th>
</tr>
</thead>
<tbody>
#foreach($companies as $company)
<a href="/bedrijf/{!! $company->CompanyId !!}">
<tr>
<td><img class="img-circle-company" src="{!! $company->Logo != null ? '/files/images/companylogos/'.$company->Logo : '/files/images/companylogos/default.png'!!}"/></td>
<td>{{ $company->CompanyName }}</td>
<td>{{ $company->City }}</td>
</tr>
</a>
#endforeach
</tbody>
</table>
</div>
But the a tag is not working why is that? In my page source it looks like this:

Unfortunately wrapping <tr> elements in an anchor isn't valid HTML. Some browsers may not blink an eye at it, but most with remove the offending element. If you want to continue using tables, another option would be to add the anchor inside each <td> element.
<div class="container col-md-6 col-md-offset-3">
<div class="well well bs-component">
<table class="table">
<thead>
<tr>
<th>Logo</th>
<th>Bedrijfsnaam</th>
<th>Plaats</th>
</tr>
</thead>
<tbody>
#foreach($companies as $company)
<tr>
<td>
<a href="/bedrijf/{!! $company->CompanyId !!}">
<img class="img-circle-company" src="{!! $company->Logo != null ? '/files/images/companylogos/'.$company->Logo : '/files/images/companylogos/default.png'!!}"/>
</a>
</td>
<td><a href="/bedrijf/{!! $company->CompanyId !!}">{{ $company->CompanyName }}</td>
<td>{{ $company->City }}</td>
</tr>
#endforeach
</tbody>
</table>
</div>
</div>

Related

Trying to get property 'name' of non-object (View: C:\xampp\htdocs\AppLaravel\resources\views\admin\editBill.blade.php)

I need to go to my bill list page but this error is stopping me: 'Trying to get property 'name' of non-object'
My route:
Route::get('bill/{id?}',[
'as'=>'bill',
'uses'=>'PageController#editBill'
]);
My Controller:
public function editBill($id)
{
$customerInfo=DB::table('customer')->select('customer.id','customer.name','customer.created_at','customer.phone_number','customer.address','customer.note','bills.total','customer.email')->join('bills','bills.id_customer','=','customer.id')->where('customer.id', '=', $id)->first();
$billInfo=Bill::where('id',$id)->get();
return view('admin.editBill',compact('customerInfo','billInfo'));
}
My view:
<section class="content">
<!-- Default box -->
<div class="box">
<div class="box-header with-border">
<div class="row">
<div class="col-md-12">
<div class="container123 col-md-6" style="">
<h4></h4>
<table class="table table-bordered">
<thead>
<tr>
<th class="col-md-4">Customer Info</th>
<th class="col-md-6"></th>
</tr>
</thead>
<tbody>
<tr>
<td>Customer name</td>
<td>{{ $customerInfo->name }}</td>
</tr>
<tr>
<td>Date Order</td>
<td>{{ $customerInfo->created_at }}</td>
</tr>
<tr>
<td>Phone Number</td>
<td>{{ $customerInfo->phone_number }}</td>
</tr>
<tr>
<td>Address</td>
<td>{{ $customerInfo->address }}</td>
</tr>
<tr>
<td>Email</td>
<td>{{ $customerInfo->email }}</td>
</tr>
<tr>
<td>Note</td>
<td>{{ $customerInfo->note }}</td>
</tr>
</tbody>
</table>
</div>
<table id="myTable" class="table table-bordered table-hover dataTable" role="grid" aria-describedby="example2_info">
<thead>
<tr role="row">
<th class="sorting col-md-1" >Id</th>
<th class="sorting_asc col-md-4">Product name</th>
<th class="sorting col-md-2">Quantity</th>
<th class="sorting col-md-2">Unit_price</th>
</thead>
<tbody>
#foreach($billInfo as $key=>$bill)
<tr>
<td>{{ $key+1 }}</td>
<td>{{ $bill->product }}</td>
<td>{{ $bill->quantity }}</td>
<td>{{ number_format($bill->unit_price) }} VNĐ</td>
</tr>
#endforeach
<tr>
<td colspan="3"><b>Total</b></td>
<td colspan="1"><b class="text-red">{{ number_format($customerInfo->total) }} đ</b></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-md-12">
<form action="{{route('pdf',$customerInfo->id)}}" method="GET">
<input type="hidden" name="_method" value="PUT">
{{ csrf_field() }}
<div class="col-md-8"></div>
<div class="col-md-4">
<div class="form-inline">
<label>Delivery Status: </label>
<select name="status" class="form-control input-inline" style="width: 200px">
<option value="1">None</option>
<option value="2">On going</option>
<option value="2">Delivered</option>
</select>
<input type="submit" method="get" value="Print" class="btn btn-primary">
</div>
</div>
</form>
</div>
</div>
</div>
</section>
The bill detail list is working fine but the customers detail is not
I tried others way like {{$customer->name ?? ''}} and it did't give an error anymore but it doesn't show any data

Skip some rows from html result in Laravel 5.7

I am developing a website in laravel.
I am using =>
Laravel version: 5.7
Xampp version: xampp-win32-7.2.8-0-VC15-installer.exe
Bootstrap version: 4.1.3
jquery version: 3.3.1
PHP version: 7.2.8
When refreshing website some rows skipped. Sometimes it is works correctly, but sometimes skipped some rows and HTML tags were broken.
For example:
blade.php:
<div class="col-lg-4 col-sm-6 mt-3">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>Title</th>
<th>Time</th>
<th>Count</th>
</tr>
</thead>
<tbody>
#forelse($bestPosts as $bestPost)
<tr>
<td>{{ $bestPost->title }}</td>
<td>{{ date('d.m.Y', strtotime($bestPost->datetime)) }}</td>
<td>{{ $bestPost->hits }}</td>
</tr>
#empty
<tr>
<td colspan="3" class="text-center bg-warning">No post</td>
</tr>
#endforelse
</tbody>
</table>
</div>
<div class="col-lg-4 col-sm-6 mt-3">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>Country</th>
<th>Year</th>
<th>Month</th>
<th>Count</th>
</tr>
</thead>
<tbody>
#forelse($newVisitors as $newVisitor)
<tr>
<td>
<img src="/flags/{{ $newVisitor->country_code3 }}.png" alt="{{ $newVisitor->country_code3 }}" class="border mr-1">
{{ $newVisitor->country_code3 }}
</td>
<td>{{ $newVisitor->year }}</td>
<td>{{ $newVisitor->month }}</td>
<td>{{ $newVisitor->count }}</td>
</tr>
#empty
<tr>
<td colspan="4" class="text-center bg-warning">No visitor</td>
</tr>
#endforelse
</tbody>
</table>
</div>
output HTML :
Ho can I solve this problem
Sometimes when refresh red lines are skipped
You are missing a < at row
img src="/flags/{{ $newVisitor->country_code3 }}.png" alt="{{ $newVisitor->country_code3 }}" class="border mr-1">
try this code :
<div class="col-lg-4 col-sm-6 mt-3">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>Title</th>
<th>Time</th>
<th>Count</th>
</tr>
</thead>
<tbody>
#if(count($bestPosts)>0)
#foreach($bestPosts as $bestPost)
<tr>
<td>{{ $bestPost->title }}</td>
<td>{{ date('d.m.Y', strtotime($bestPost->datetime)) }}</td>
<td>{{ $bestPost->hits }}</td>
</tr>
#endforeach
#else
<tr>
<td colspan="3" class="text-center bg-warning">No post</td>
</tr>
#endif
</tbody>
</table>
</div>
<div class="col-lg-4 col-sm-6 mt-3">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>Country</th>
<th>Year</th>
<th>Month</th>
<th>Count</th>
</tr>
</thead>
<tbody>
#if(count($newVisitors)>0)
#foreach($newVisitors as $newVisitor)
<tr>
<td>
<img src="{{ '/flags/'.$newVisitor->country_code3 }}.png" alt="{{ $newVisitor->country_code3 }}" class="border mr-1" />
{{ $newVisitor->country_code3 }}
</td>
<td>{{ $newVisitor->year }}</td>
<td>{{ $newVisitor->month }}</td>
<td>{{ $newVisitor->count }}</td>
</tr>
#endforeach
#else
<tr>
<td colspan="4" class="text-center bg-warning">No visitor</td>
</tr>
#endif
</tbody>
</table>
</div>

Disable Button if Variants are empty

So I have this forelse that displays all the variants, now what I want to happen is that, if there is no variant. the submit button will be disabled.
<table class="table table-striped">
<thead>
<tr>
<th class="col-sm-5">Name</th>
<th class="col-sm-1">Default?</th>
<th class="col-sm-2 text-right">Retail Price</th>
<th class="col-sm-2 text-right">Quantity</th>
<th class="col-sm-2"></th>
</tr>
</thead>
<tbody>
#forelse ($product->variants as $index => $variant)
<tr>
<td>{{ $variant->name }}</td>
<td>{{ $variant->is_default ? 'Yes' : 'No' }}</td>
<td class="text-right">{{ number_format($variant->retail_price, 2) }} {{ $variant->price_currency }}</td>
<td class="text-right">{{ number_format($variant->quantity, 0) }}</td>
<td>Edit</td>
</tr>
#empty
<tr>
<td colspan="5">No variants found</td>
<?php $varbutton = 'disabled';?>
</tr>
#endforelse
</tbody>
</table>
here is the button
<div class="panel-footer">
<button class="btn btn-default" type="submit"<?php $varbutton; ?>>Update Store</button>
</div>
Is it possible using php and html in the blade alone or do I have to do it in the controller?
You should be using blade in your button:
<div class="panel-footer">
<button class="btn btn-default" type="submit" {{ $varbutton }}>Update Store</button>
</div>
Also please note that there needs to be a space after "submit".
Or, if you don't want that space when the button is not disabled, use:
<?php $varbutton = ' disabled';?>
<div class="panel-footer">
<button class="btn btn-default" type="submit"{{ $varbutton }}>Update Store</button>
</div>

POST method of <form> is not working inside #foreach on blade file in laravel 5.6

Button doesnot work after using form inside #foreach. Any suggestion about how to use form inside a #foreach loop ?
is it even possible to use form inside a loop in laravel blade file?
here is my code of my laravel blade file. I have used form inside foreach for getting data of Book Amount. Any Suggestion about how to solve this problem?
#extends('layouts.app')
#section('content')
<div class="container">
<h1>Items On Cart:</h4>
<div class="row justify-content-center">
<div class="col-md-12">
<div class="card">
<div class="card-body">
#if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
#endif
<table style="border-collapse: collapse;width: 100%;">
<tr style="border: 1px solid #dddddd;text-align: left;padding: 8px;font-size:20px;color: gray">
<th>Book Name</th>
<th>Author Name</th>
<th>Book Amount</th>
<th>Price</th>
<th>Action</th>
<th>Action</th>
</tr>
#foreach($cart_items as $data)
<form action="{{ route('change_item_amount',[$cart_info->id,$data->book_id]) }}" method="POST">
<tr>
<th>{{ show_books_name($data->book_id) }}</th>
<th>{{ show_books_author($data->book_id) }}</th>
<th><input type="number" name="amount" id="amount" value="{{ $data->item_amount }}"></th>
<th>{{ $data->price }} tk</th>
<th><button type="submit" class="btn btn-success">Change</button></th>
<th><a class="btn btn-success" href="{{ route('delete_book',[$cart_info->id,$data->book_id] ) }}">Delete</a></th>
</form>
#endforeach
</table>
</div>
<h2 style="padding-left:865px">Total = {{ $cart_info->total_price }} tk</h2>
</div>
</form>
</div>
</div>
</div>
#endsection
The simplest solution can be: place a form tag into a td, (btw it should be td, not th, you use th in thead):
<table style="border-collapse: collapse;width: 100%;">
<tr style="border: 1px solid #dddddd;text-align: left;padding: 8px;font-size:20px;color: gray">
<th>Book Name</th>
<th>Author Name</th>
<th>Book Amount</th>
<th>Price</th>
<th>Action</th>
<th>Action</th>
</tr>
#foreach($cart_items as $data)
<tr>
<td>{{ show_books_name($data->book_id) }}</td>
<td>{{ show_books_author($data->book_id) }}</td>
<td> <!-- Here we have empty td now --> </td>
<td>{{ $data->price }} tk</td>
<td>
<!-- Form is here now -->
<form action="{{ route('change_item_amount',[$cart_info->id,$data->book_id]) }}" method="POST">
<input type="number" name="amount" id="amount" value="{{ $data->item_amount }}">
<button type="submit" class="btn btn-success">Change</button>
</form>
</td>
<td><a class="btn btn-success" href="{{ route('delete_book',[$cart_info->id,$data->book_id] ) }}">Delete</a></td>
#endforeach
</table>

Convert to pdf "Frame not found in cellmap"

I'm building an invoice system, first you'll have to fill in the products you want to have on your invoice then it will convert the html view(where it will show the products in a foreach loop) to pdf. But if I have more than 6 products it will throw the following exception:
Frame not found in cellmap
I know this question has been asked a lot. But it seems there is still no real solution. It occurs when the input on the page is bigger than the first page and it can't jump to a new page so it throws an error:
Already tried a lottt!
This won't work for me:
$paper_orientation = 'landscape';
$customPaper = array(0,0,950,950);
$dompdf->set_paper($customPaper,$paper_orientation);
https://github.com/dompdf/dompdf/issues/657
This is my html view:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Factuur</title>
<link rel="stylesheet" href="/administration/style.css" media="all" />
</head>
<body>
<header class="clearfix">
<img src="/administration/logo.png">
<div id="company">
<h2 class="name">Company name</h2>
<div>Address</div>
<div>zip</div>
<div>email</div>
</div>
</div>
</header>
<main>
<div id="details" class="clearfix">
<div id="client">
<div class="to">{{ $sort == 0 ? 'Offerte' : 'Factuur' }} voor:</div>
<h2 class="name">{{ $company }}</h2>
<div class="address">{{ $address }}</div>
<div class="address">{{ $zip }}</a></div>
</div>
<div>
<h1>{{ $sort == 0 ? 'Offerte' : 'Factuur' }}nummer: {{ $number }}</h1>
<div class="date">Datum: {{ $date }}</div>
</div>
</div>
<table border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th class="no">#</th>
<th class="desc">Beschrijving</th>
<th class="unit">Prijs</th>
<th class="qty">Aantal</th>
<th class="total">Totaal</th>
</tr>
</thead>
<tbody>
#foreach($products as $product)
<tr>
<td class="no">{{ $product->id }}</td>
<td class="desc"><h3>{{ $product->title }}</h3>{{ $product->description }}</td>
<td class="unit">€{{ $product->price }}</td>
<td class="qty">{{ $product->number }}</td>
<td class="total">€{{ $product->total }}</td>
</tr>
#endforeach
</tbody>
<tfoot>
<tr>
<td colspan="2"></td>
<td colspan="2">SUBTOTAAL</td>
<td>€ {{ $subtotal }}</td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="2">BTW 21%</td>
<td>€ {{ $btw }}</td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="2">TOTAAL</td>
<td>€ {{ $total }}</td>
</tr>
</tfoot>
</table>
<div id="notices" class="{{ $sort == 0 ? 'hidePayment' : 'notices' }}">
<div>BETALING:</div>
</div>
</main>
<footer>
KvK nummer: | BTW nummer:
</footer>
</body>
</html>
Is there a solution?

Categories