public function getRequiredFields()
    {
        $rules = $this->getRules();

        $requiredFields = array_where(
            $rules, function ($value, $key) {
                if (is_array($value)) {
                    $value = implode('|', $value);
                }

                return str_contains($value, ['required', 'sometimes']);
            }
        );

        return $requiredFields;
    }
public function getRequiredFields()
    {
        $rules = $this->getRules();

        $requiredFields = array_where(
            $rules, function ($value, $key) {
                if (is_array($value)) {
                    $value = implode('|', $value);
                }

                return str_contains($value, ['required', 'sometimes']);
            }
        );

        return $requiredFields;
    }
public function getRequiredFields ( ) { $ rules = $ this -> getRules ( ) ; $ requiredFields = array_where ( $ rules , function ( $ value , $ key ) { if ( is_array ( $ value ) ) { $ value = implode ( '|' , $ value ) ; } return str_contains ( $ value , [ 'required' , 'sometimes' ] ) ; } ) ; return $ requiredFields ; }
Get required fields.

@return array
Get required fields .