I'm a Laravel developer.
datlechin / flarum-birthdays Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
On my test instance I've upgraded Flarum to 1.7.0. Since then if I attempt to make any profile changes while the setting "Required entering Birthdays" option is selected, I get the error "The Birthday Field is Required" even if a birthday has been entered for my user. I have tried disabling the extension and purging all data for it to start over, but this doesn't seem to have any impact.
Unfortunately I don't know which log file I'd need to look at for more helpful debugging information; none that I've looked at (Flarum's error.log, php's fpm log, or nginx's error/access log) have anything occurring at the same time as the bug, with the exception of the POST attempt from me actually submitting whatever profile changes I was attempting to make.
public function __invoke(UserValidator $flarumValidator, Validator $validator): void
{
$rules = $validator->getRules();
$isRequired = $this->settings->get('datlechin-birthdays.required')
&& $this->settings->get('datlechin-birthdays.set_on_registration');
if ($isRequired && ! $flarumValidator->getUser()) {
$set_isRequired = 'required';
} else {
$set_isRequired = 'nullable';
}
$rules['birthday'] = [
//'nullable',
//Rule::requiredIf($isRequired && ! $flarumValidator->getUser()),
$set_isRequired,
'date_format:Y-m-d',
'before:today',
function ($attribute, $value, $fail) {
if ($value) {
$birthday = new DateTime($value);
$now = new DateTime();
$diff = $now->diff($birthday);
if ($diff->y <= (int) $this->settings->get('datlechin-birthdays.min_age')) {
$fail($this->translator->trans('datlechin-birthdays.api.invalid_age_message', [
'minAge' => (int) $this->settings->get('datlechin-birthdays.min_age')
]));
} else if ($diff->y > 100) {
$fail($this->translator->trans('datlechin-birthdays.api.invalid_dob_message'));
}
}
},
];
$validator->setRules($rules);
}
Displaying the user's age, and year of birth should be optional. For many users, the day and month alone are enough to show birthdays.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.