Level 102
You cannot set a property dynamically outside of a method.
public function foo()
{
$this->errorBag = $this->isMethod('patch') ? 'visit' . $this->visit->id : 'new';
}
1 like
I want to conditionally set $errorBag property inside Form Request:
protected $errorBag = $this->isMethod('patch') ? 'visit' . $this->visit->id : 'new';
but it gives me this error:
Constant expression contains invalid operations
Is there any way to do this?
You cannot set a property dynamically outside of a method.
public function foo()
{
$this->errorBag = $this->isMethod('patch') ? 'visit' . $this->visit->id : 'new';
}
Please or to participate in this conversation.