How to access '$this' in rules? #150
Answered
by
juse-less
francoism90
asked this question in
Q&A
-
I know you can use the Unique rule, however I would like to use it on Livewire:
How can one call $this->id? |
Beta Was this translation helpful? Give feedback.
Answered by
juse-less
Jul 4, 2022
Replies: 2 comments 8 replies
-
You should be able to access the I didn't check the documentation right now, but immediately recalled PR #123. public static function rules(array $payload): array
{
return [
'post.name' => ['required', 'string', 'max:40', 'unique:'.Post::class.',name,'.$payload['id']],
];
} |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
francoism90
-
And how you do this with
|
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should be able to access the
$id
property, by addingarray $payload
to yourrules()
method.I didn't check the documentation right now, but immediately recalled PR #123.