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

vincent15000's avatar

Call to a member function getQueueableRelations() on bool

Hello,

In a Livewire component ...

I have authors with roles (author, illustrator, co-author, ...), I can add as many roles as I want in the database.

To add / edit an author, I have to check the right roles.

I have this view.

@foreach ($roles as $index => $role)
    <div wire:key="role-field-.{{ $index }}" class="form-check">
        <input wire:model="author.roles.{{ $index }}" class="form-check-input" type="checkbox" value="{{ $role->id }}" id="role.{{ $index }}">
        <label class="form-check-label" for="role.{{ $index }}">{{ $role->name }}</label>
    </div>
@endforeach

When I check a checkbox, all is ok.

When I uncheck a checkbox, I have this error.

Call to a member function getQueueableRelations() on string

I don't understand what string it is ...

Do you have any idea ?

Thanks for your help.

Vincent

0 likes
5 replies
vincent15000's avatar

@Sinnbeck Ok ... in the component I also have a datatable (I will probably separate the datatable and the form, but for now I have this).

<?php

namespace App\Http\Livewire\Admin;

use Livewire\Component;
use Livewire\WithPagination;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

use App\Models\Author;
use App\Models\Role;

class AdminAuthors extends Component
{

    use AuthorizesRequests;

    use WithPagination;

    public $perPage = 20;
    public $perPageOptions = [5, 10, 20, 100];

    public $sortField = 'firstname';
    public $asc = true;

    public $search = '';

    public Author $author;
    public $formTitle;
    public $updateMode;
    public $rules;
    public $messages;

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

    public function sortBy($field)
    {
        if ($this->sortField === $field)
        {
            $this->asc = ! $this->asc;
        }
        else
        {
            $this->asc = true;
        }
        $this->sortField = $field;
    }

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

    public function initForm($id = null)
    {
        if ($id) {
            $this->author = Author::find($id);
            $this->formTitle = 'Editer l\'auteur '.$this->author->fullname;
            $this->updateMode = true;
        } else {
            $this->author = new Author;
            $this->formTitle = 'Ajouter un nouvel auteur';
            $this->updateMode = false;
        }
        $this->rules = $this->author->getValidationRules();
        $this->messages = $this->author->getValidationMessages();
    }

    public function edit($id)
    {
        $this->initForm($id);
    }

    public function save()
    {
        $this->validate($this->rules, $this->messages);
        if ($this->updateMode) {
            $this->authorize('update', $this->author);
            $this->author->update();
        } else {
            $this->authorize('create', $this->author);
            $this->author->save();
        }
        $this->dispatchBrowserEvent('closeModal');
        $this->initForm();
    }

    public function cancel()
    {
        $this->dispatchBrowserEvent('closeModal');
        $this->initForm();
    }

    public function delete($id)
    {
        $author = Author::find($id);
        $author->delete();
    }

    public function render()
    {

        $searches = explode(' ', $this->search);
        $searches = array_diff($searches, ['']);

        $authors = Author::
            when(count($searches) > 0, function ($query) use ($searches) {
                foreach ($searches as $search) {
                    $query->where(function ($query) use($search) {
                        $query
                            ->where('authors.firstname', 'like', '%'.$search.'%')
                            ->orWhere('authors.lastname', 'like', '%'.$search.'%');
                    });
                }
            })
            ->orderByRaw('`'.$this->sortField.'` '.($this->asc ? 'asc' : 'desc'))
            ->paginate($this->perPage);

        $roles = Role::orderBy('order')->get();

        return view('livewire.admin.admin-authors', compact('authors', 'roles'))->layout('layouts.member');

    }

}
vincent15000's avatar

@Sinnbeck And perhaps you want to see the rules.


public function getValidationRules()
{
    return [
        'author.firstname' => 'required|string',
        'author.lastname' => 'string|nullable',
        'author.website' => 'string|nullable|unique:authors,website,'.$this->id.',id',
        'author.roles.*' => 'boolean',
    ];
}

public function getValidationMessages()
{
    return [

        'author.firstname.required' => 'Le prénom est obligatoire.',
        'author.firstname.string' => 'Le prénom doit être une chaîne de caractères.',

        'author.lastname.string' => 'Le nom doit être une chaîne de caractères.',

        'author.website.string' => 'Le site internet doit être une chaîne de caractères.',
        'author.website.unique' => 'Ce site internet existe déjà.',

    ];
}

The rule for author.roles.* cannot be null, I have removed null in the rule, now the error message is :

Call to a member function getQueueableRelations() on bool
vincent15000's avatar

@Sinnbeck I just found something like this.

@foreach ($roles as $index => $role)
    <div wire:key="role-field-.{{ $index }}" class="form-check">
        <input wire:model="rolesArray" class="form-check-input" type="checkbox" value="{{ $role->id }}" id="role.{{ $index }}">
        <label class="form-check-label" for="role.{{ $index }}">{{ $role->name }}</label>
    </div>
@endforeach

Now it works, but I'd like to list all the existing roles and that only the selected ones are checked. Is it possible to bind this automatically with wire:model and authorsroles ?

vincent15000's avatar
vincent15000
OP
Best Answer
Level 63

I have a solution.

I use a public selectedRoles array which contains the ids of the selected roles and I bind it in the view. It works fine.

Please or to participate in this conversation.