Show us where you are using the createPermission method; all we see for now is the Component class, which tells us nothing about how you use it... You could be calling the method on an instance of a completely different class!
Nov 25, 2024
1
Level 1
Unable to call component method. Public method [createPermission] not found on component
I experienced problems in the Livewire project when I wanted to implement the createPermission feature in the Laravel 11 Livewire 3 component.
app/Livewire/CreatePermission.php
<?php
namespace App\Livewire;
use Livewire\Component;
use Spatie\Permission\Models\Permission;
class CreatePermission extends Component
{
public $name;
public function createPermission()
{
$validatedData = $this->validate([
'name' => 'required|string|max:255|unique:permissions,name',
]);
Permission::create($validatedData);
session()->flash('message', 'Permission created successfully.');
}
public function render()
{
return view('livewire.create-permission');
}
}
Error : Internal Server Error Livewire\Exceptions\MethodNotFoundException Unable to call component method. Public method [createPermission] not found on component.
I have tried many times to make the component very simple for initial implementation before I make modifications.
Give me help from all of you who know whether there is an error in the code I created?
Please or to participate in this conversation.