HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/posscale/public_html/printmanager/app/Http/Controllers/Tenant/PrinterType.php
<?php

namespace App\Http\Controllers\Tenant;

use App\Http\Controllers\Controller;
use App\Models\PrinterType as ModelsPrinterType;
use Illuminate\Http\Request;
use App\Http\Requests\TenantRequest;
use App\Http\Requests\PrinterTypeRequest;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;

class PrinterType extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index(Request $request)
    {
       
        abort_unless(auth()->user()?->can('manage_printers'), 403);

        $search = $request->input('search');
        
        $printer_type = ModelsPrinterType::whereAny([
            'type_title',
            'toner_type',
            'drum_unit',
            'fuser_unit',
            'paper_tray',
        ], 'LIKE', '%' . $search . '%')->paginate(15);
        return view('tenant.printer_type.list', ['printer_type' => $printer_type, 'search' => $search]);
    }

     /**
     * Show the form for creating a new resource.
     */
    public function create()
    {
        abort_unless(auth()->user()?->can('manage_printers'), 403);

        return view('tenant.printer_type.form', ['printer_type' => [], 'action' => 'Add Printer Type']);
    }

    public function store(PrinterTypeRequest $request)
    {
        abort_unless(auth()->user()?->can('manage_printers'), 403);

        if ($request->header('X-Precognitive')) {
            // Handle precognitive request, usually just return the validation response
            return response()->json(['message' => 'Precognitive request validated successfully.']);
        }
        
        $printer = new ModelsPrinterType([
            'type_title'      => $request->type_title,
            'toner_type'      => $request->toner_type,
            'drum_unit'      => $request->drum_unit,
            'fuser_unit'      => $request->fuser_unit,
            'paper_tray'      => $request->paper_tray,
            'paper_feed_rollers' => $request->paper_feed_rollers,
            'duplex_unit'      => $request->duplex_unit,
            'transfer_belt'      => $request->transfer_belt,
            'toner_discreptions'      => $request->toner_discreptions,            
        ]);
        $printer->save();

        return Redirect::route('printer-type.index')->with('message', 'Printer type created successfully.');
    }

    /**
     * Display the specified resource.
     */
    public function show($id)
    {
        return view('tenant.printer_type.show', [
            'printer_type' => ModelsPrinterType::findOrFail($id)
        ]);
    }

    /**
     * Show the form for editing the specified resource.
     */
    public function edit($id)
    {
        abort_unless(auth()->user()?->can('manage_printers'), 403);

        $printer_type = ModelsPrinterType::findOrFail($id);
        return view('tenant.printer_type.form', ['printer_type' => $printer_type, 'action' => 'Edit Printer Type']);
    }

    /**
     * Update the specified resource in storage.
    */
    public function update(PrinterTypeRequest $request, ModelsPrinterType $printer_type)
    {
      
        abort_unless(auth()->user()?->can('manage_printers'), 403);
        
        $printer_type->type_title    = $request->type_title;
        $printer_type->toner_type  =  $request->toner_type;
        $printer_type->drum_unit =  $request->drum_unit;
        $printer_type->fuser_unit   =  $request->fuser_unit;
        $printer_type->paper_tray   =  $request->paper_tray;
        $printer_type->paper_feed_rollers   = $request->paper_feed_rollers;
        $printer_type->duplex_unit   = $request->duplex_unit;
        $printer_type->transfer_belt   = $request->transfer_belt;
        $printer_type->toner_discreptions   =$request->toner_discreptions;
        $printer_type->save();        
        return Redirect::route('printer-type.index')->with('message', 'Printer type updated successfully.');
    }

    /**
     * Remove the specified resource from storage.
     */
    public function destroy(ModelsPrinterType $printer_type)
    {
        abort_unless(auth()->user()?->can('manage_printers'), 403);

        $printer_type->delete();
        return Redirect::route('printer-type.index')->with('message', 'Printer type delete successfully.');
    }


}