WallyJ
6 months ago
2566
11
Laravel

Livewire component's public property 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.

Posted 6 months ago by WallyJ

I'm receiving the following error:

Livewire component's [contactshow] public property [contactnotes] 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.

I can't tell what I'm doing wrong. Here's my code:

Livewire Controller:

<?php

namespace App\Http\Livewire;

use Livewire\Component;
use App\Task;

class Contactshow extends Component
{

    public $contacts;
    public $tasktext;
    public $dealId;
    public $taskduedate;
    public $deal_id;
    public $contactnotes;

    public function mount($contacts)
    {
        $this->contacts = $contacts;
        $this->contactnotes = $this->contacts->contactnotes()->paginate();
    }

    public function render()
    {
        return view('livewire.contactshow');
    }

}

Livewire Component View:

<div class="row">
   <div class="col-md-12">
      <ul class="list-group">
         @foreach($this->contactnotes as $contactnote)
            <li class="list-group-item">
               {{$contactnote->created_at}} - {{$contactnote->contactnotetext}}
            </li>
         @endforeach
      </ul>
   </div>
</div>

Please sign in or create an account to participate in this conversation.