In my AddUser Livewire component I have the following rule:
#[Rule('required|max:50|unique:users,name')]
public $name;
Which of course does it’s job. But when I’m trying to update a user in the database and I have the following rule:
#[Rule('required|max:50|unique:users,name,' . $this->user?->id)]
I am getting an error with this:
Constant expression contains invalid operations
I am trying to understand what I am doing wrong, since this is what I would do normally in Laravel, and I cannot find anything online about this. Any explanation and/or solution to make it work without having to use public function rules()
?