<?php #CodeGenerator V3 Δ 7ed849252dc67bcb73710860375b1161 Δ DYNAMICALLY GENERATED FILE - Do not modify this line! Remove it completely to protect the file from changes.
/**
 * Livewire Component
 *
 * @version     1.0.$Revision:$
 * @version     SVN: $Id:$
 * @version     STUB: 2.0.0
 * @generated   2026-07-21 14:12:38
 * @package     bplan-base/globals
 * @subpackage  LivewireComponents
 * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
 * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
 * @copyright   Copyright (C) 2025, 2026 bplan-solutions GmbH & Co. KG <https://www.bplan-solutions.de/>
 * /Δ\
 */

namespace BplanBase\Globals\Livewire\PrinterHost\Modals;


use BplanBase\Globals\Models\PrinterHost;
use BplanBase\Globals\Services\PrinterHostService;
use Livewire\Attributes\On;
use Livewire\Component;


/**
 * Livewire Component
 *
 * @version     1.0.0 / 2026-07-21
 * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
 * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
 */
class Edit extends Component
{


/* +++ TRAITS +++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */


/* +++ CLASS CONSTANTS +++ ++++++++++++++++++++++++++++++++++++++++++++++++++ */


/* +++ OBJECT MEMBERS +++ +++++++++++++++++++++++++++++++++++++++++++++++++++ */


    /**
     * @var     PrinterHostService
     */
    protected PrinterHostService $_Service;


/* +++ CLASS MEMBERS +++ ++++++++++++++++++++++++++++++++++++++++++++++++++++ */


    /**
     * @var
     */
    private static $_logPrefix = 'PrinterHost/Modals/Edit';


/* +++ OBJECT METHODS +++ +++++++++++++++++++++++++++++++++++++++++++++++++++ */


    /**
     *
     * @param       PrinterHostService $Service
     *
     * @version     1.0.0 / 2026-07-21
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function boot(PrinterHostService $Service)
    {
        $this->_Service = $Service;

    } // boot()


    /**
     *
     * @return      void
     *
     * @version     1.0.0 / 2026-07-21
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function deletePrinterHost()
    {
        $this->authorize('printer-host.delete');

        try {
            $this->_Service->delete($this->printerHost->id);
            $User = auth()->user();

            \AppLog::info('PrinterHost deleted by ['.$User->name.' ('.$User->email.')]', self::$_logPrefix);

            $this->dispatch('printer-host-deleted');

        } catch (\Throwable $th) {
            $TraceCode = \TraceCode::capture();

            \AppLog::error($th, self::$_logPrefix, TraceCode: $TraceCode);

            $this->dangerBanner(__('bplan-base/globals::printer-hosts.error.delete-error', ['trace-code' => $TraceCode]));
        }
    } // deletePrinterHost()


    /**
     *
     * @return      void
     *
     * @version     1.0.0 / 2026-07-21
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function editPrinterHost()
    {
        $this->authorize('printer-host.update');

        $this->validate();

        try {
            $this->_Service->update($this->printerHost->id, []);
            $User = auth()->user();

            \AppLog::info('PrinterHost edited by ['.$User->name.' ('.$User->email.')]', self::$_logPrefix);

            $this->dispatch('init-tippyjs');
            $this->dispatch('printer-host-edited');

        } catch (\Throwable $th) {
            $TraceCode = \TraceCode::capture();

            \AppLog::error($th, self::$_logPrefix, TraceCode: $TraceCode);

            $this->dangerBanner(__('bplan-base/globals::printer-hosts.error.update-error', ['trace-code' => $TraceCode]));
        }
    } // editPrinterHost()


    /**
     *
     * @param       PrinterHost $printerHost
     *
     * @return      void
     *
     * @version     1.0.0 / 2026-07-21
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
//    #[On('show-create-printer-host-modal')]
//    public function initPrinterHost(PrinterHost $printerHost)
//    {
//        $this->printerHost = $printerHost;
//
////        $this->name = $user->name;
////        $this->email = $user->email;
////        $this->selectedRoles = [];
////
////        foreach ($user->roles as $key => $role) {
////            $this->selectedRoles[$role->id] = true;
////        }
//        $this->dispatch('init-tippyjs');
//
//    } // initPrinterHost()


    /**
     *
     * @version     1.0.0 / 2026-07-21
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function mount()
    {
        //
    } // mount()


    /**
     *
     * @version     1.0.0 / 2026-07-21
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function render()
    {
        return view('globals::livewire.printer-host.modals.edit');

    } // render()


    /**
     *
     * @return      array
     *
     * @version     1.0.0 / 2026-07-21
     * @author      Emilio Cannarozzo <emilio.cannarozzo@bplan-solutions.de>
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function rules(): array
    {
        $rules = [];

        return $rules;

    } // rules()


/* +++ CLASS METHODS +++ ++++++++++++++++++++++++++++++++++++++++++++++++++++ */


} // class Edit extends Component {}
