如何在数据表上显示具体数据
How to show specifics data on datatable
我想问一下...
如何分离数据表上的特定数据?按 SKU
个数字过滤。
我想做 2 个表而不是 SKU Produk
SKU Code = "11-------" is for table 1
SKU Code = "33-------" is for table 2
Produk-Image
@extends('layout.master')
@section('title', 'Daftar Produk')
@section('parentPageTitle', 'Produk')
@section('page-style')
<link rel="stylesheet" href="{{asset('assets/plugins/jquery-datatable/dataTables.bootstrap4.min.css')}}"/>
<link rel="stylesheet" href="{{asset('assets/plugins/sweetalert/sweetalert.css')}}"/>
@stop
@section('content')
@include('sweetalert::alert')
<div class="row clearfix">
<div class="col-lg-12">
<div class="card">
<div class="body">
<div>
<a href="{{ route('produk.create')}}" class="btn btn-success btn-round" data-type="confirm"> <i class="zmdi zmdi-account-add"></i> Tambah Produk</a>
<a style="margin: 2px;" href="{{ route('produk.index')}}" class="btn btn-primary btn-sm"><i class="zmdi zmdi-refresh"></i></a>
</div>
<div class="col-sm-12">
@if(session()->get('success'))
<div class="alert alert-success">
{{ session()->get('success') }}
</div>
@endif
</div>
<table class="table table-bordered table-striped table-hover dataTable js-exportable">
<thead>
<tr>
<th class="align-middle text-center" style="width:5%">#</th>
<th class="align-middle text-center" style="width:15%">SKU</th>
<th class="align-middle text-center" style="width:28%">Nama Produk</th>
<th class="align-middle text-center" style="width:11%">Harga Beli</th>
<th class="align-middle text-center" style="width:11%">Harga Jual</th>
<th class="align-middle text-center" style="width:15%">Status</th>
<th class="align-middle text-center" style="width:15%">Aksi</th>
</tr>
</thead>
<tbody>
@if(!empty($datas) && $datas->count())
@foreach($datas as $data)
<tr>
<td class="align-middle text-center">{{$loop->iteration}}</td>
<td class="align-middle text-center">{{$data->sku}}</td>
<td class="align-middle">{{$data->p_nama}}</td>
{{-- <td class="align-middle">Rp. {{ number_format($data->p_jual,0) }}</td> --}}
<td class="align-middle">Rp. {{ number_format($data->p_beli,0) }}</td>
<td class="align-middle">Rp. {{ number_format($data->p_harga,0) }}</td>
@if($data->status == 'tersedia')
<td class="align-middle text-center">
<label class="badge badge-success" ><strong>Tersedia</strong></label>
</td>
@else
<td class="align-middle text-center">
<label class="badge badge-default" ><strong>Tidak Dijual</strong></label>
</td>
@endif
{{-- <td class="align-middle text-center">{{$data->status}}</td> --}}
<td class="align-middle text-center">
{{-- <a href="{{ route('produk.show',$data->id)}}" title="Lihat" class="btn btn-primary btn-icon btn-icon-mini btn-round"> <i class="zmdi zmdi-eye"></i> </a> --}}
<button title="Lihat" class="btn btn-primary btn-icon btn-icon-mini btn-round" data-toggle="modal" data-target="#lihat"> <i class="zmdi zmdi-eye"></i> </button>
<a href="{{ route('produk.edit', $data->id)}}" title="Ubah" class="btn btn-warning btn-icon btn-icon-mini btn-round"> <i class="zmdi zmdi-edit"></i></span></a>
<a href="{{ route('produk.delete', $data->id)}}" title="Hapus" class="btn btn-danger btn-icon btn-icon-mini btn-round" data-type="success"> <i class="zmdi zmdi-delete"></i></span></a>
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="8">Data tidak ditemukan! Silahkan buat data Produk terlebih dahulu.</td>
</tr>
@endif
</tbody>
</table>
{{-- {!! $datas->links() !!} --}}
</div>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-lg-12">
<div class="card">
<div class="body">
<div>
<a href="{{ route('produk.create')}}" class="btn btn-success btn-round" data-type="confirm"> <i class="zmdi zmdi-account-add"></i> Tambah Produk</a>
<a style="margin: 2px;" href="{{ route('produk.index')}}" class="btn btn-primary btn-sm"><i class="zmdi zmdi-refresh"></i></a>
</div>
<div class="col-sm-12">
@if(session()->get('success'))
<div class="alert alert-success">
{{ session()->get('success') }}
</div>
@endif
</div>
<table class="table table-bordered table-striped table-hover dataTable js-exportable">
<thead>
<tr>
<th class="align-middle text-center" style="width:5%">#</th>
<th class="align-middle text-center" style="width:15%">SKU</th>
<th class="align-middle text-center" style="width:28%">Nama Produk Kopi</th>
<th class="align-middle text-center" style="width:11%">Harga Beli</th>
<th class="align-middle text-center" style="width:11%">Harga Jual</th>
<th class="align-middle text-center" style="width:15%">Status</th>
<th class="align-middle text-center" style="width:15%">Aksi</th>
</tr>
</thead>
<tbody>
@if(!empty($datas) && $datas->count())
@foreach($datas as $data)
<tr>
<td class="align-middle text-center">{{$loop->iteration}}</td>
<td class="align-middle text-center">{{$data->sku}}</td>
<td class="align-middle">{{$data->p_nama}}</td>
{{-- <td class="align-middle">Rp. {{ number_format($data->p_jual,0) }}</td> --}}
<td class="align-middle">Rp. {{ number_format($data->p_beli,0) }}</td>
<td class="align-middle">Rp. {{ number_format($data->p_harga,0) }}</td>
@if($data->status == 'tersedia')
<td class="align-middle text-center">
<label class="badge badge-success" ><strong>Tersedia</strong></label>
</td>
@else
<td class="align-middle text-center">
<label class="badge badge-default" ><strong>Tidak Dijual</strong></label>
</td>
@endif
{{-- <td class="align-middle text-center">{{$data->status}}</td> --}}
<td class="align-middle text-center">
{{-- <a href="{{ route('produk.show',$data->id)}}" title="Lihat" class="btn btn-primary btn-icon btn-icon-mini btn-round"> <i class="zmdi zmdi-eye"></i> </a> --}}
<button title="Lihat" class="btn btn-primary btn-icon btn-icon-mini btn-round" data-toggle="modal" data-target="#lihat"> <i class="zmdi zmdi-eye"></i> </button>
<a href="{{ route('produk.edit', $data->id)}}" title="Ubah" class="btn btn-warning btn-icon btn-icon-mini btn-round"> <i class="zmdi zmdi-edit"></i></span></a>
<a href="{{ route('produk.delete', $data->id)}}" title="Hapus" class="btn btn-danger btn-icon btn-icon-mini btn-round" data-type="success"> <i class="zmdi zmdi-delete"></i></span></a>
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="8">Data tidak ditemukan! Silahkan buat data Produk terlebih dahulu.</td>
</tr>
@endif
</tbody>
</table>
{{-- {!! $datas->links() !!} --}}
</div>
</div>
</div>
</div>
<!-- Lihat modal -->
<div class="modal fade" id="lihat" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title" id="exampleModalCenterTitle">Detail Produk</h2>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="row clearfix">
<div class="col-sm-12">
<div class="card">
<div class="body">
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
<br />
@endif
<table class="table table-hover dataTable js-exportable">
<tbody>
<tr height="40px">
<th class="align-middle" style="width:18%"><b>Barcode</b></th>
<td class="align-middle" style="width:2%">:</td>
<td class="align-middle" style="width:28%">
<div class="barcode align-middle">
{!! DNS1D::getBarcodeHTML($data->sku, "C128",2.2,60) !!}
</div>
</td>
<th class="align-middle" style="width:18%"><b>QR Code</b></th>
<td class="align-middle" style="width:2%">:</td>
<td class="align-middle">
<div class="barcode" rowspan="2">
{!! QrCode::size(100)->generate($data->sku); !!}
</div>
</td>
</tr>
<tr height="60px">
<th class="align-middle" style="width:18%"><b>Nama Produk</b></th>
<td class="align-middle" style="width:2%">:</td>
<td class="align-middle" style="width:25%">{{ $data->p_nama }}</td>
<th class="align-middle" style="width:18%"></th>
<td class="align-middle" style="width:2%"></td>
<td class="align-middle" style="width:25%"></td>
</tr>
<tr height="60px">
<th class="align-middle" style="width:18%"><b>Harga Beli</b></th>
<td class="align-middle" style="width:2%">:</td>
<td class="align-middle text-danger"><strong>Rp. {{ number_format($data->p_beli,0) }}</strong> ,-</td>
<th class="align-middle" style="width:18%"><b>Harga Jual</b></th>
<td class="align-middle" style="width:2%">:</td>
<td class="align-middle text-danger"><strong>Rp. {{ number_format($data->p_harga,0) }}</strong> ,-</td>
</tr>
<tr height="60px">
<th class="align-middle" style="width:18%"><b>Dibuat pada</b></th>
<td class="align-middle" style="width:2%">:</td>
<td class="align-middle" style="width:25%">{{ $data->created_at->isoFormat('dddd, D MMMM Y') }}</td>
<th class="align-middle" style="width:18%"><b>Diupdate pada</b></th>
<td class="align-middle" style="width:2%">:</td>
<td class="align-middle">{{ $data->updated_at->diffForHumans() }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<a href="{{ route('produk.index')}}" class="btn btn-primary"><i class="zmdi zmdi-undo"></i> Simpan Perubahan</a>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
@stop
@section('page-script')
<script src="{{asset('assets/bundles/datatablescripts.bundle.js')}}"></script>
<script src="{{asset('assets/plugins/jquery-datatable/buttons/dataTables.buttons.min.js')}}"></script>
<script src="{{asset('assets/plugins/jquery-datatable/buttons/buttons.bootstrap4.min.js')}}"></script>
<script src="{{asset('assets/plugins/jquery-datatable/buttons/buttons.colVis.min.js')}}"></script>
<script src="{{asset('assets/plugins/jquery-datatable/buttons/buttons.flash.min.js')}}"></script>
<script src="{{asset('assets/plugins/jquery-datatable/buttons/buttons.html5.min.js')}}"></script>
<script src="{{asset('assets/plugins/jquery-datatable/buttons/buttons.print.min.js')}}"></script>
<script src="{{asset('assets/js/pages/tables/jquery-datatable.js')}}"></script>
<script src="{{asset('assets/plugins/sweetalert/sweetalert.min.js')}}"></script>
<script src="{{asset('assets/js/pages/ui/sweetalert.js')}}"></script>
@stop
您可以为 SKU 代码 11 和 SKU 代码 33 创建两个 table。您需要使用 SKU 代码进行筛选
@foreach($datas as $data)
@if(str_starts_with($data->sku, '11'))
<tr>
<td>...</td>
</tr>
@endif
@endforeach
我想问一下...
如何分离数据表上的特定数据?按 SKU
个数字过滤。
我想做 2 个表而不是 SKU Produk
SKU Code = "11-------" is for table 1
SKU Code = "33-------" is for table 2
Produk-Image
@extends('layout.master')
@section('title', 'Daftar Produk')
@section('parentPageTitle', 'Produk')
@section('page-style')
<link rel="stylesheet" href="{{asset('assets/plugins/jquery-datatable/dataTables.bootstrap4.min.css')}}"/>
<link rel="stylesheet" href="{{asset('assets/plugins/sweetalert/sweetalert.css')}}"/>
@stop
@section('content')
@include('sweetalert::alert')
<div class="row clearfix">
<div class="col-lg-12">
<div class="card">
<div class="body">
<div>
<a href="{{ route('produk.create')}}" class="btn btn-success btn-round" data-type="confirm"> <i class="zmdi zmdi-account-add"></i> Tambah Produk</a>
<a style="margin: 2px;" href="{{ route('produk.index')}}" class="btn btn-primary btn-sm"><i class="zmdi zmdi-refresh"></i></a>
</div>
<div class="col-sm-12">
@if(session()->get('success'))
<div class="alert alert-success">
{{ session()->get('success') }}
</div>
@endif
</div>
<table class="table table-bordered table-striped table-hover dataTable js-exportable">
<thead>
<tr>
<th class="align-middle text-center" style="width:5%">#</th>
<th class="align-middle text-center" style="width:15%">SKU</th>
<th class="align-middle text-center" style="width:28%">Nama Produk</th>
<th class="align-middle text-center" style="width:11%">Harga Beli</th>
<th class="align-middle text-center" style="width:11%">Harga Jual</th>
<th class="align-middle text-center" style="width:15%">Status</th>
<th class="align-middle text-center" style="width:15%">Aksi</th>
</tr>
</thead>
<tbody>
@if(!empty($datas) && $datas->count())
@foreach($datas as $data)
<tr>
<td class="align-middle text-center">{{$loop->iteration}}</td>
<td class="align-middle text-center">{{$data->sku}}</td>
<td class="align-middle">{{$data->p_nama}}</td>
{{-- <td class="align-middle">Rp. {{ number_format($data->p_jual,0) }}</td> --}}
<td class="align-middle">Rp. {{ number_format($data->p_beli,0) }}</td>
<td class="align-middle">Rp. {{ number_format($data->p_harga,0) }}</td>
@if($data->status == 'tersedia')
<td class="align-middle text-center">
<label class="badge badge-success" ><strong>Tersedia</strong></label>
</td>
@else
<td class="align-middle text-center">
<label class="badge badge-default" ><strong>Tidak Dijual</strong></label>
</td>
@endif
{{-- <td class="align-middle text-center">{{$data->status}}</td> --}}
<td class="align-middle text-center">
{{-- <a href="{{ route('produk.show',$data->id)}}" title="Lihat" class="btn btn-primary btn-icon btn-icon-mini btn-round"> <i class="zmdi zmdi-eye"></i> </a> --}}
<button title="Lihat" class="btn btn-primary btn-icon btn-icon-mini btn-round" data-toggle="modal" data-target="#lihat"> <i class="zmdi zmdi-eye"></i> </button>
<a href="{{ route('produk.edit', $data->id)}}" title="Ubah" class="btn btn-warning btn-icon btn-icon-mini btn-round"> <i class="zmdi zmdi-edit"></i></span></a>
<a href="{{ route('produk.delete', $data->id)}}" title="Hapus" class="btn btn-danger btn-icon btn-icon-mini btn-round" data-type="success"> <i class="zmdi zmdi-delete"></i></span></a>
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="8">Data tidak ditemukan! Silahkan buat data Produk terlebih dahulu.</td>
</tr>
@endif
</tbody>
</table>
{{-- {!! $datas->links() !!} --}}
</div>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-lg-12">
<div class="card">
<div class="body">
<div>
<a href="{{ route('produk.create')}}" class="btn btn-success btn-round" data-type="confirm"> <i class="zmdi zmdi-account-add"></i> Tambah Produk</a>
<a style="margin: 2px;" href="{{ route('produk.index')}}" class="btn btn-primary btn-sm"><i class="zmdi zmdi-refresh"></i></a>
</div>
<div class="col-sm-12">
@if(session()->get('success'))
<div class="alert alert-success">
{{ session()->get('success') }}
</div>
@endif
</div>
<table class="table table-bordered table-striped table-hover dataTable js-exportable">
<thead>
<tr>
<th class="align-middle text-center" style="width:5%">#</th>
<th class="align-middle text-center" style="width:15%">SKU</th>
<th class="align-middle text-center" style="width:28%">Nama Produk Kopi</th>
<th class="align-middle text-center" style="width:11%">Harga Beli</th>
<th class="align-middle text-center" style="width:11%">Harga Jual</th>
<th class="align-middle text-center" style="width:15%">Status</th>
<th class="align-middle text-center" style="width:15%">Aksi</th>
</tr>
</thead>
<tbody>
@if(!empty($datas) && $datas->count())
@foreach($datas as $data)
<tr>
<td class="align-middle text-center">{{$loop->iteration}}</td>
<td class="align-middle text-center">{{$data->sku}}</td>
<td class="align-middle">{{$data->p_nama}}</td>
{{-- <td class="align-middle">Rp. {{ number_format($data->p_jual,0) }}</td> --}}
<td class="align-middle">Rp. {{ number_format($data->p_beli,0) }}</td>
<td class="align-middle">Rp. {{ number_format($data->p_harga,0) }}</td>
@if($data->status == 'tersedia')
<td class="align-middle text-center">
<label class="badge badge-success" ><strong>Tersedia</strong></label>
</td>
@else
<td class="align-middle text-center">
<label class="badge badge-default" ><strong>Tidak Dijual</strong></label>
</td>
@endif
{{-- <td class="align-middle text-center">{{$data->status}}</td> --}}
<td class="align-middle text-center">
{{-- <a href="{{ route('produk.show',$data->id)}}" title="Lihat" class="btn btn-primary btn-icon btn-icon-mini btn-round"> <i class="zmdi zmdi-eye"></i> </a> --}}
<button title="Lihat" class="btn btn-primary btn-icon btn-icon-mini btn-round" data-toggle="modal" data-target="#lihat"> <i class="zmdi zmdi-eye"></i> </button>
<a href="{{ route('produk.edit', $data->id)}}" title="Ubah" class="btn btn-warning btn-icon btn-icon-mini btn-round"> <i class="zmdi zmdi-edit"></i></span></a>
<a href="{{ route('produk.delete', $data->id)}}" title="Hapus" class="btn btn-danger btn-icon btn-icon-mini btn-round" data-type="success"> <i class="zmdi zmdi-delete"></i></span></a>
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="8">Data tidak ditemukan! Silahkan buat data Produk terlebih dahulu.</td>
</tr>
@endif
</tbody>
</table>
{{-- {!! $datas->links() !!} --}}
</div>
</div>
</div>
</div>
<!-- Lihat modal -->
<div class="modal fade" id="lihat" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title" id="exampleModalCenterTitle">Detail Produk</h2>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="row clearfix">
<div class="col-sm-12">
<div class="card">
<div class="body">
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
<br />
@endif
<table class="table table-hover dataTable js-exportable">
<tbody>
<tr height="40px">
<th class="align-middle" style="width:18%"><b>Barcode</b></th>
<td class="align-middle" style="width:2%">:</td>
<td class="align-middle" style="width:28%">
<div class="barcode align-middle">
{!! DNS1D::getBarcodeHTML($data->sku, "C128",2.2,60) !!}
</div>
</td>
<th class="align-middle" style="width:18%"><b>QR Code</b></th>
<td class="align-middle" style="width:2%">:</td>
<td class="align-middle">
<div class="barcode" rowspan="2">
{!! QrCode::size(100)->generate($data->sku); !!}
</div>
</td>
</tr>
<tr height="60px">
<th class="align-middle" style="width:18%"><b>Nama Produk</b></th>
<td class="align-middle" style="width:2%">:</td>
<td class="align-middle" style="width:25%">{{ $data->p_nama }}</td>
<th class="align-middle" style="width:18%"></th>
<td class="align-middle" style="width:2%"></td>
<td class="align-middle" style="width:25%"></td>
</tr>
<tr height="60px">
<th class="align-middle" style="width:18%"><b>Harga Beli</b></th>
<td class="align-middle" style="width:2%">:</td>
<td class="align-middle text-danger"><strong>Rp. {{ number_format($data->p_beli,0) }}</strong> ,-</td>
<th class="align-middle" style="width:18%"><b>Harga Jual</b></th>
<td class="align-middle" style="width:2%">:</td>
<td class="align-middle text-danger"><strong>Rp. {{ number_format($data->p_harga,0) }}</strong> ,-</td>
</tr>
<tr height="60px">
<th class="align-middle" style="width:18%"><b>Dibuat pada</b></th>
<td class="align-middle" style="width:2%">:</td>
<td class="align-middle" style="width:25%">{{ $data->created_at->isoFormat('dddd, D MMMM Y') }}</td>
<th class="align-middle" style="width:18%"><b>Diupdate pada</b></th>
<td class="align-middle" style="width:2%">:</td>
<td class="align-middle">{{ $data->updated_at->diffForHumans() }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<a href="{{ route('produk.index')}}" class="btn btn-primary"><i class="zmdi zmdi-undo"></i> Simpan Perubahan</a>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
@stop
@section('page-script')
<script src="{{asset('assets/bundles/datatablescripts.bundle.js')}}"></script>
<script src="{{asset('assets/plugins/jquery-datatable/buttons/dataTables.buttons.min.js')}}"></script>
<script src="{{asset('assets/plugins/jquery-datatable/buttons/buttons.bootstrap4.min.js')}}"></script>
<script src="{{asset('assets/plugins/jquery-datatable/buttons/buttons.colVis.min.js')}}"></script>
<script src="{{asset('assets/plugins/jquery-datatable/buttons/buttons.flash.min.js')}}"></script>
<script src="{{asset('assets/plugins/jquery-datatable/buttons/buttons.html5.min.js')}}"></script>
<script src="{{asset('assets/plugins/jquery-datatable/buttons/buttons.print.min.js')}}"></script>
<script src="{{asset('assets/js/pages/tables/jquery-datatable.js')}}"></script>
<script src="{{asset('assets/plugins/sweetalert/sweetalert.min.js')}}"></script>
<script src="{{asset('assets/js/pages/ui/sweetalert.js')}}"></script>
@stop
您可以为 SKU 代码 11 和 SKU 代码 33 创建两个 table。您需要使用 SKU 代码进行筛选
@foreach($datas as $data)
@if(str_starts_with($data->sku, '11'))
<tr>
<td>...</td>
</tr>
@endif
@endforeach