<?php
use App\Model\product\ProductImageModel;
?>
@if(@$stock_item && count($stock_item) > 0)
    @foreach ($stock_item as $row)
        <?php
        $my_p = getProductById($row->product_id);
        $product_name = $my_p ? $my_p->product_name : "";
        $barcode = $row ? $row->barcode : "";
        $category_name = $my_p ? optional($my_p->get_category)->category_name : "";
        $unit = findUnit($my_p->unit_id)->unit??'';
        $sub_unit = findUnit($my_p->child_unit)->unit??'';
        $img = ProductImageModel::where('product_id',$row->product_id ??'')->first()->images??'';
        $stock_qty = (int)($row->stock_qty/$row->qty_per_unit);
        ?>
        <div class="col-lg-3 col-md-6 po-box" title="{{$product_name}}">
            <div class="btn btn-default" style="width: 100%">
                <a class="listings cursor"
                   data-name="{{$product_name}}"
                   data-code="{{$barcode}}"
                   data-stock="{{$stock_qty}}"
                   data-qty_per_unit="{{$row->qty_per_unit}}"
                   data-id="{{ $row->product_id }}">
                    <div class="bg-img" style="
                        background: url({{findImg($img)}});
                        height: 130px;
                        width: 100%;
                        background-position: center;
                        background-size: cover;
                        background-repeat: no-repeat;
                        ">
                    </div>
                    <ul class="item-show-name">
                        <span style="
                        left:10px;
                        top: 10px;

                                background: #337ab7;
                                font-weight: 100;
                                border-radius: 0 0 4px 0;
                                position: absolute;" class="label text-left">{{$stock_qty}} {{$unit}}
                                   ក្នុងស្តុក</span>
                        <li>{{$barcode}} ({{"$row->qty_per_unit $sub_unit"}})</li>
                        <li>{{ str_limit($product_name,20) }} </li>
                    </ul>
                </a>
            </div>
        </div>

    @endforeach
@endif
<div class="col-sm-12 col-xs-12">
    <div class="pagin">
        @if(@$stock_item)
            {!! $stock_item->render() !!}
        @endif
    </div>
</div>

