laravel exists already validation rules code example
Example 1: custom rule laravel validation
public function store()
{
$this->validate(request(), [
'song' => [function ($attribute, $value, $fail) {
if ($value <= 10) {
$fail(':attribute needs more cowbell!');
}
}]
]);
}
Example 2: validation rule if row exist laravel
//update request
return [
'username' => 'unique:users,username,' . $this->route('internalUser')->id . ',id',
];
//create request
return [
'username' => 'unique:users'
];