Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Chris1989's avatar

Laravel Livewire problem after update

Recently i make a composer update, and now i get error on specific pages on my application:

I searched that must update to the latest version of livewire , but seems that isnt updating to the latest,

Look my composer.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "php": "^7.3|^8.0",
        "barryvdh/laravel-dompdf": "^0.9.0",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "7.0",
        "intervention/image": "^2.7",
        "laravel/framework": "^8.40",
        "laravel/jetstream": "^2.3",
        "laravel/sanctum": "^2.6",
        "laravel/tinker": "^2.5",
        "laraveldaily/laravel-invoices": "^2.0",
        "livewire/livewire": "^2.0"
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.6",
        "facade/ignition": "^2.5",
        "fakerphp/faker": "^1.9.1",
        "laravel/sail": "^1.0.1",
        "mockery/mockery": "^1.4.2",
        "nunomaduro/collision": "^5.0",
        "phpunit/phpunit": "^9.3.3"
    },
    "autoload": {
        "psr-4": {
            "App\": "app/",
            "Database\Factories\": "database/factories/",
            "Database\Seeders\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    },
    
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

and the error:

Livewire\Exceptions\PublicPropertyTypeNotAllowedException
Livewire component's [invoices.incomes-show] public property [data] must be of type: [numeric, string, array, null, or boolean]. Only protected or private properties can be set as other types because JavaScript doesn't need to access them.
0 likes
4 replies
Chris1989's avatar

@abdulrehmandar2234 Here:

<?php

namespace App\Http\Livewire\Invoices;

use Livewire\Component;
use App\Models\Customer;
use App\Models\Service;
use Illuminate\Support\Facades\Validator;
use Carbon\Carbon;
use App\Models\PaymentInvoice;
use App\Models\PaymentInvoiceItems;

use Illuminate\Support\Facades\Http;

use LaravelDaily\Invoices\Invoice;
use LaravelDaily\Invoices\Classes\Buyer;
use LaravelDaily\Invoices\Classes\Party;
use LaravelDaily\Invoices\Classes\InvoiceItem;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Illuminate\Http\Request;

use Livewire\WithPagination;
 

class IncomesShow extends Component
{

    use WithPagination;
    
    public $sortBy = 'id';
    public $sortDirection = 'asc';
    public $perPage = '10';
    public $invoiceID;
    public $inv_comments,$cost,$vat_percentage,$inv_date,$start_date ,$end_date;
    public $search;
  

    public $modalConfirmDeleteVisible,$modalInvoiceFormVisible , $modalFormVisible ,$selectAll= false;

    public function deleteShowModal($invoiceID)
    {
        $this->invoiceID = $invoiceID;
        $this->modalConfirmDeleteVisible = true;
    }

    public function delete()
    {
        if(PaymentInvoiceItems::where('invoice_id', $this->invoiceID)->delete());
        PaymentInvoice::destroy($this->invoiceID);
     

        $this->modalConfirmDeleteVisible = false;
        $this->resetPage();
        $this->dispatchBrowserEvent('alert', ['type' => 'error', 'message' => 'Data Deleted!']);
    }

    public function updateModal($invoiceID)
    {
        $this->invoiceID = $invoiceID;
        $this->modalFormVisible = true;

        $this->loadInvoice();

    }

    public function loadInvoice()
    {

        $invoice = PaymentInvoice::find($this->invoiceID);
        
         
      
        $this->start_date=$invoice->service->start_date ? $invoice->service->start_date->format('Y-m-d') : $invoice->service->start_date;
        $this->end_date=$invoice->service->end_date ? $invoice->service->end_date->format('Y-m-d') : $invoice->service->end_date;
        $this->inv_date = $invoice->inv_date->format('Y-m-d'); 
        $this->inv_comments = $invoice->inv_comments;
        $this->cost = $invoice->cost;

        $this->vat_percentage = $invoice->vat_percentage;

       

    }
    protected function rules()
    {

        return [
          
            'cost' => 'required',
            'vat_percentage' => 'required',

        ];

    }

    
    public function update()
    {
        $this->validate();

        $invoice = PaymentInvoice::where('id',$this->invoiceID)->with('service','main_invoice')->first();
       
        $total_cost = null;
        $total_vat_cost = floatval($this->cost * $this->vat_percentage / 100);
        $vat_percentage = $this->vat_percentage;
        $Withholding = null;
        $WithholdingPercentage = null;
       
        if  (($invoice->invoice_type == "service_invoice") && (($invoice->service->type == "Subscription" && $invoice->service->name == "Support")) && $this->cost >= floatval(300)) {
            
            $FinalCost = floatval($this->cost + ($this->cost * $vat_percentage / 100));
            $WithholdingPercentage = 20;
            $Withholding = floatval($this->cost * $WithholdingPercentage / 100);

            $total_cost = $FinalCost - $Withholding;
        } else {
            $total_cost = floatval($this->cost * $this->vat_percentage / 100) + $this->cost;
        }
        
        $data = [
           
            'inv_comments' => $this->inv_comments,
            'inv_date' => $this->inv_date, 
            'cost' => $this->cost, 
            'vat_percentage' => $vat_percentage,
            'total_cost' => $total_cost,
            'total_vat_cost' => $total_vat_cost,
            'with_holding' => $Withholding,
            'with_holding_percentage' => $WithholdingPercentage
        ];
       
      

        PaymentInvoice::find($this->invoiceID)->update($data);

        //close modal form
        $this->modalFormVisible = false;
        //Show success message
        $this->dispatchBrowserEvent('alert', ['type' => 'info', 'message' => 'Data Edited!']);
    }

    public function sortBy($field)
    {
        if ($this->sortDirection == 'asc') {
            $this->sortDirection = 'desc';
        } else {
            $this->sortDirection = 'asc';
        }
        return $this->sortBy = $field;
    }

    public function mount()
    {
        
        $this->resetPage();
    }

    public function invoice($invoiceID)
    { 
     
        $invoice = PaymentInvoice::where('id', $invoiceID)->with('items.service', 'customer', 'website')->first();

        $seller = new Party([
            'name' => 'NetGen',
            'phone' => '(+30) 694 2624846',

            'custom_fields' => [
                // 'note' => 'IDDQD',
                // 'Λογ.Τραπέζης' => '23423423432',
            ],
        ]);

        $customer = new Party([
            'name' => $invoice->customer->name,
            'custom_fields' => [
                'Επωνυμία' => $invoice->customer->brand_name ? $invoice->customer->brand_name : "null",
                'Επάγγελμα' => $invoice->customer->profession ? $invoice->customer->profession : "null",
                'ΑΦΜ' => $invoice->customer->vat ? $invoice->customer->vat : "null",
                'Website' => $invoice->website->name,
                'Email' => $invoice->customer->email ? $invoice->customer->email : "null",
                'Διεύθυνση' => $invoice->customer->address ? $invoice->customer->address : "null",
                'ΔΟΥ' => $invoice->customer->doi ? $invoice->customer->doi : "null",
                'ΤΚ' => $invoice->customer->postal_code ? $invoice->customer->postal_code : "null",
                
            ],
        ]);

        $items = [];
        foreach ($invoice->items as $invoiceItem) {
            array_push($items,
                (new InvoiceItem())->title($invoiceItem->service->name)->pricePerUnit($invoiceItem->cost)->subTotalPrice($invoiceItem->total_cost),
            );
        }
 

        $invoice = Invoice::make('receipt')
            ->setCustomData([
                'reference_invoice_id' =>  !empty($invoice->main_invoice->invoice_id) ? $invoice->main_invoice->invoice_id  : NULL,
                'vat_percentage' => $invoice->vat_percentage,
                'invoice_type' => ucwords(str_replace("_", " ", $invoice->invoice_type)),
                'invoice_id' => $invoice->invoice_id,
                'with_holding' => $invoice->with_holding,
                'payment_type' => $invoice->payment_type,
                'invoice_items' => $invoice->items,
                'main_invoice_type' => $invoice->main_invoice_type,
                'invoice_comments' => $invoice->inv_comments,
                'invoice_date' => $invoice->inv_date,
                'vat' => $invoice->total_vat_cost,
            ])
            ->series('NETGEN')
        
            ->serialNumberFormat('{SEQUENCE}')

            ->seller($seller)
            ->buyer($customer)
            ->date($invoice->created_at)
            ->dateFormat('d/m/Y')
            ->payUntilDays(14)
            ->currencySymbol('€')
            ->currencyCode('EURO')
            ->currencyFormat('{SYMBOL}{VALUE}')
            ->currencyThousandsSeparator('.')
            ->currencyDecimalPoint(',')
            ->taxableAmount($invoice->cost)
            ->totalTaxes($invoice->total_vat_cost)
            ->totalAmount($invoice->total_cost)
            ->filename($seller->name . ' ' . $customer->name)
            ->addItems($items)
       
            ->logo(public_path('/img/logo.png'));
      
        $this->modalInvoiceFormVisible = false;
        $this->dispatchBrowserEvent('alert', ['type' => 'success', 'message' => 'Invoice Created Successfully!']);
        $invoices = PaymentInvoice::where('id', $invoiceID)->with('items.service', 'customer', 'website')->first();

        $link = $invoice->url();
        return response()->streamDownload(function () use ($invoice) {
            echo $invoice->stream();
        }, 'Invoice_'.$customer->name.'_'.$invoices->inv_date->format('d-m-Y').'.pdf');

           
       

    } 
    
    public function render(Request $request)
    {   
       
        $this->data = PaymentInvoice::query()
            ->with('items')   

            ->search($this->search)

            ->orderBy($this->sortBy, $this->sortDirection)

            ->paginate($this->perPage);


        return view('livewire.invoices.IncomesShow', ['invoices' => $this->data])

        ->extends('layouts.maindashboard')
        ->section('content');
    }
}

AbdulRehmanDar's avatar
Level 2

In your render method, you are using $this->data but data is not defined as public property just remove $this from data only use $data.

 public function render(Request $request)
    {   
       
        $data = PaymentInvoice::query()
            ->with('items')   

            ->search($this->search)

            ->orderBy($this->sortBy, $this->sortDirection)

            ->paginate($this->perPage);


        return view('livewire.invoices.IncomesShow', ['invoices' => $data])

        ->extends('layouts.maindashboard')
        ->section('content');
    }
1 like
Chris1989's avatar

@abdulrehmandar2234

Wow, worked, but how broke that unexpectedly without change anything? Also is there any way to make an auto upgrade all of my dependencies automatically? Because im pretty sure that i dont have the latest.

Please or to participate in this conversation.