please help me.
Trying to get property of non-object (View:
/Data/oa-dev4/resources/views/surat_tugas/list_surat_tugas/table_total.blade.php)
(View:
/Data/oa-dev4/resources/views/surat_tugas/list_surat_tugas/table_total.blade.php)
<div class="caption">
<i class="fa fa-table font-blue-oa"></i>
<span class="caption-subject font-blue-oa sbold uppercase">Rekap Biaya dan Pelaksanaan Surat Tugas Tahun {{$tahun_st}}</span>
</div>
<div class="portlet-body">
<table class="table table-datatable table-bordered table-checkable table-hover">
<thead>
<tr class="heading">
<th class='hidden'></th>
<th class="text-center"> </th>
<th class="text-center"> Jumlah Hari </th>
<th class="text-center"> Transport </th>
<th class="text-center"> Penginapan</th>
<th class="text-center"> Uang Harian</th>
<th class="text-center"> Jumlah</th>
</tr>
</thead>
<tbody>
<tr>
<td class='sbold'>Total</td>
#if($rekap->jumlah_hari)
<td class="text-right">{{$rekap->jumlah_hari}} Hari</td>
#else
<td class="text-right"> - </td>
#endif
#if(Helper::convert_rupiah($rekap->transport))
<td class="text-right">{{Helper::convert_number($rekap->transport)}}</td>
#else
<td class="text-right"> - </td>
#endif
#if(Helper::convert_rupiah($rekap->penginapan))
<td class="text-right">{{Helper::convert_number($rekap->penginapan)}}</td>
#else
<td class="text-right"> - </td>
#endif
#if(Helper::convert_rupiah($rekap->harian))
<td class="text-right">{{Helper::convert_number($rekap->harian)}}</td>
#else
<td class="text-right"> - </td>
#endif
#if(Helper::convert_rupiah($rekap->transport) || Helper::convert_rupiah($rekap->transport)|| Helper::convert_rupiah($rekap->transport))
<td class="text-right">{{Helper::convert_number($rekap->transport + $rekap->harian + $rekap->penginapan)}}</td>
#else
<td class="text-right"> - </td>
#endif
<tr>
</tbody>
</table>
</div>
The following error means you are accessing a value that is not an object.
Trying to get property of non-object
If the $rekap variable is an array then you have to convert it into an object and then access is in you blade template.
Related
I want Make Different on Table, Each table has a service name Dontt Need Loop Again Table same Group Name, Each group has the name of the service
Check : https://i.ibb.co/NTnynGq/639.png
View : Package.blade.php
<div class="pt-120 pb-120">
<div class="container">
<div class="row justify-content-center">
<div class="col-lg-12">
<div class="table-responsive--md">
<div class="services-table w-100">
<div class="service-group">
<div class="card">
#foreach($packages as $singlePackage)
<br>
<table class="table table-bordered style--two">
<thead>
<tr>
<th style="width:70%">
<span>Group Name : {{ $singlePackage->groups->name }}</span>
</th>
<th style="width:15%">
<span>#lang('Services Name')</span>
</th>
<th style="width:15%">
<span>#lang('Services Name')</span>
</th>
<th style="width:15%">
<span>#lang('Action')</span>
</th>
</tr>
</thead>
<tbody>
<tr class="block item">
<td class="word-break">{{ $singlePackage->name }}</td>
<td>
<span>{{ $singlePackage->delivery_time }}</span>
</td>
<td>
<span>{{ $singlePackage->price }}</span>
</td>
<td>
<span>{{ $singlePackage->price }}</span>
</td>
</tr>
</tbody>
</table>
#endforeach
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Package Model
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Package extends Model
{
protected $guarded = ['id'];
public function groups()
{
return $this->belongsTo(Group::class);
}
}
PackageController.php
public function packages()
{
$pageTitle = 'Packages';
$packages = Package::where('status', 1)->with('groups')->paginate(getPaginate());
return view('package',compact('pageTitle', 'packages'));
}
Want Separation each group has the name of the service
Option 1: You can add an ORDER BY group_id in the query
$packages = Package::where('status', 1)->with('groups')->orderBy('group_id')->paginate(getPaginate());
Option 2: You can sort by the group name in the foreach
#foreach($packages->sortBy(function ($item) { return $item->group->name; }) as $singlePackage)
or
#foreach($packages->sortBy(fn($item) => $item->group->name) as $singlePackage)
Option 3: Use the Collection's groupBy method.
<div class="card">
#foreach($packages->groupBy(function ($item) { return $item->groups->name; }) as $name => $group)
<br>
<table class="table table-bordered style--two">
<thead>
<tr>
<th style="width:70%">
<span>Group Name : {{ $name }}</span>
</th>
<th style="width:15%">
<span>#lang('Services Name')</span>
</th>
<th style="width:15%">
<span>#lang('Services Name')</span>
</th>
<th style="width:15%">
<span>#lang('Action')</span>
</th>
</tr>
</thead>
<tbody>
#foreach($group as $singlePackage)
<tr class="block item">
<td class="word-break">{{ $singlePackage->name }}</td>
<td>
<span>{{ $singlePackage->delivery_time }}</span>
</td>
<td>
<span>{{ $singlePackage->price }}</span>
</td>
<td>
<span>{{ $singlePackage->price }}</span>
</td>
</tr>
#endforeach
</tbody>
</table>
#endforeach
</div>
I am working with DOMPDF in Laravel 8, when I create a table with many records and jumps to the next page, it does not perform the page break as it should, Could someone help me to know what I am doing wrong?. I was reading many articles on the internet and none of them worked for me.
Here is my code:
<div class="box-products-table">
<table class="table table-striped table-bordered">
<tbody>
<tr>
<td class="text-center roboto">{{ trans('image') }}</td>
<td class="text-center roboto">{{ trans('just_name') }}</td>
<td class="text-center roboto">{{ trans('quantity') }}</td>
<td class="text-center roboto">{{ trans('unit_price') }}</td>
<td class="text-center roboto">{{ trans('taxes') }}</td>
<td class="text-center roboto">{{ trans('subtotal') }}</td>
<td class="text-center roboto">{{ trans('total_price') }}</td>
</tr>
#for($i = 0; $i < 100; $i++)
<tr>
<td class="text-center"><img src="{{ public_path('storage/uploads/products/d6d74f351d482bb41787e86350ace02e.jpg') }}" height="70px"></td>
<td class="text-center">PORTATIL DELL 4HWRT</td>
<td class="text-right">526</td>
<td class="text-right">$ 4.985.650</td>
<td class="text-right">$ 947.273,5</td>
<td class="text-right">$ 99.713.000</td>
<td class="text-right">$ 2.622.451.900</td>
</tr>
#endfor
</tbody>
</table>
</div>
Result:
Go to screenshot (https://ibb.co/Rj5ZPTW)
.page_break {
page-break-before: always;
}
<!-- adjust $n as needed. $n = number of rows that fit in a page -->
#foreach(collect(range(1,100))->chunk($n) as $chunk)
<div class="box-products-table">
<table class="table table-striped table-bordered">
<tbody>
<tr>
<td class="text-center roboto">{{ trans('image') }}</td>
<td class="text-center roboto">{{ trans('just_name') }}</td>
<td class="text-center roboto">{{ trans('quantity') }}</td>
<td class="text-center roboto">{{ trans('unit_price') }}</td>
<td class="text-center roboto">{{ trans('taxes') }}</td>
<td class="text-center roboto">{{ trans('subtotal') }}</td>
<td class="text-center roboto">{{ trans('total_price') }}</td>
</tr>
#foreach($chunk as $i)
<tr>
<td class="text-center"><img src="{{ public_path('storage/uploads/products/d6d74f351d482bb41787e86350ace02e.jpg') }}" height="70px"></td>
<td class="text-center">PORTATIL DELL 4HWRT</td>
<td class="text-right">526</td>
<td class="text-right">$ 4.985.650</td>
<td class="text-right">$ 947.273,5</td>
<td class="text-right">$ 99.713.000</td>
<td class="text-right">$ 2.622.451.900</td>
</tr>
#endforeach
</tbody>
</table>
</div>
<div class="page-break"></div> <!-- break page -->
#endforeach
i want to generate pdf from the database for 1 row in a table , the table name is "listings"
i used that script for the controller :
class CreatePdfController extends Controller
{
public function pdfForm(Request $request,$id){
$listing = Listing::findOrFail($id);
view()->share('listing',$listing);
if($request->has('download')){
$pdf = PDF::loadView('pdf_download');
return $pdf->download('pdf_download.pdf');
}
return view('show_details')->with('listing', $listing);
}
}
and for the show_details its the view where can i fetch just the data for 1 line in the table :
<div class="col-sm-8 offset-sm-2">
Download PDF
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header col-xs-6">
<div class="col-xs-3">
<h2>Listing Ref n° :{{$listing->id}}</h2>
{{$listing->owner->owner_lastname}}</h4>
</div>
<div class="col-xs-3">
<img src="{{ asset('/assets/images/listings/'.$listing->listing_Fimage) }}" width="120px" height="100px" alt="image" >
</div>
</div>
<div class="card-body">
<div class="col-xs-7 well">
<table id="example1" class="table table-bordered">
<thead>
<tr>
<th scope="row">listing_title:</th>
<td>{{$listing->listing_title}}</td>
</tr>
<tr>
<th scope="row">listing_type:</th>
<td>{{$listing->listing_type}}</td>
</tr>
<tr>
<th scope="row">listing_purpose:</th>
<td>{{$listing->listing_purpose}}</td>
</tr>
<tr>
<th scope="row">listing_location:</th>
<td>{{$listing->listing_location}}</td>
</tr>
<tr>
the pdf_download is the view that i want to generated as pdf :
<table id="example1" class="table table-bordered">
<thead>
<tr>
<th scope="row">listing_title:</th>
<td>{{$listing->listing_title}}</td>
</tr>
<tr>
<th scope="row">listing_type:</th>
<td>{{$listing->listing_type}}</td>
</tr>
<tr>
<th scope="row">listing_purpose:</th>
<td>{{$listing->listing_purpose}}</td>
</tr>
<tr>
<th scope="row">listing_location:</th>
<td>{{$listing->listing_location}}</td>
</tr>
<tr>
<th scope="row">listing_emirate:</th>
<td>{{$listing->listing_emirate}}</td>
</tr>
<tr>
<th scope="row">listing_community:</th>
<td>{{$listing->listing_community}}</td>
</tr>
<tr>
<th scope="row">listing_price:</th>
<td>{{$listing->listing_price}}</td>
</tr>
</table>
and the route that i passed is :
Route::get('/show_details/{id}' ,array('as'=>'show_details',
'uses'=>'CreatePdfController#pdfForm'));
the problem is i get that error and i cannot download the pdf file :
**Symfony\Component\ErrorHandler\Error\FatalError
Maximum execution time of 60 seconds exceeded
http://127.0.0.1:8000/show_details/3?download=pdf**
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>
I am having some trouble writing some nested HTML Tables from my Laravel Collection.
My Model
public static function offers($userId)
{
return DB::table('users_vehicles')
->join('dealer_offers', 'users_vehicles.id', '=', 'dealer_offers.vehicle_id')
->where('user_id', '=', $userId)
->select('users_vehicles.*', 'dealer_offers.*');
}
My Controller
public function dash()
{
$userCars = UserVehicles::offers(Auth::user()->id)->get();
return view('customer.dash', compact('userCars'));
}
My Collection Results
In My View blade Template
#foreach( $userCars->chunk(1) as $userCarChunk)
<div id="no-more-tables">
<table class="table table-bordered table-hover">
<caption>Offers for My Mazda 326 </caption>
<thead>
<tr>
<th class="numeric">DEALER RATING</th>
<th class="numeric">AMOUNT </th>
<th class="numeric"> 3 DAYS To Accept </th>
</tr>
</thead>
<tbody>
#foreach( $userCarChunk as $car)
<tr>
<td data-title="First Name">
<div class="rating">
<label>
<input type="radio" name="rating" value="5" title="5 stars"> 5
</label>
</div>
</td>
<td data-title="Last Name"> 55 000 </td>
<td data-title="Username">
Accept
</td>
</tr>
#endforeach
</tbody>
</table>
</div>
#endforeach
Front-End View
Question
How can I create a nested HTML Table for all the user vehicles, so that I can write the vehicle name and all the offers for that particular vehicle?
I hope my question is clear.
Try it like this :
<div id="no-more-tables">
<table class="table table-bordered table-hover">
<caption>Offers for My Mazda 326 </caption>
<thead>
<tr>
<th class="numeric">DEALER RATING</th>
<th class="numeric">AMOUNT </th>
<th class="numeric"> 3 DAYS To Accept </th>
</tr>
</thead>
<tbody>
#foreach( $userCars->chunk(1) as $userCarChunk)
#foreach( $userCarChunk as $car)
<tr>
<td data-title="First Name">
<div class="rating">
<label>
<input type="radio" name="rating" value="5" title="5 stars"> 5
</label>
</div>
</td>
<td data-title="Last Name"> 55 000 </td>
<td data-title="Username">
Accept
</td>
</tr>
#endforeach
#endforeach
</tbody>
</table>
</div>
Answer
My Model UserVehicles.php
public function offers() {
return $this->hasMany(DealerOffers::class, 'vehicle_id');
}
My Controller CustomerController.php
$offersToCustomer = UserVehicles::with('offers')->get();
Dashboard Blade template
#foreach( $offersToCustomer as $offer)
<div id="no-more-tables_">
<table class="table table-bordered table-hover">
<caption>Offers for My :: <b style="color: #00BFF0"> {{ $offer->vehicle_make }} {{ $offer->vehicle_model }} </b> </caption>
<thead>
<tr>
<th class="numeric">DEALER RATING</th>
<th class="numeric">AMOUNT REQUESTED </th>
<th class="numeric">AMOUNT OFFERED </th>
<th class="numeric"> Expires :: {{ Carbon\Carbon::parse($offer->offer_expiry)->format('d-m-Y') }} </th>
</tr>
</thead>
<tbody>
#foreach( $offer->offers as $subOffer)
<tr>
<td data-title="DEALER RATING">
<input id="rating" name="rating" class="rating rating-loading" value="3" data-min="0" data-max="5" data-step="1" />
</td>
<td data-title="AMOUNT REQUESTED">R {{ number_format($offer->vehicle_amount_asked, 2, '.', ' ') }} </td>
<td data-title="AMOUNT OFFERED">R {{ number_format($subOffer->offer_amount, 2, '.', ' ') }} </td>
<td data-title="ACTIONS">
<button data-offer_id="{{ $offer->id }} " data-vehicle_id="{{ $subOffer->vehicle_id }}"
class="btn btn-xs btn-success accept-offer">Accept</button>
</td>
</tr>
#endforeach
</tbody>
</table>
</div>
#endforeach
Output