*"Ardent is a lightweight, open-source package that embeds validation logic directly into Laravel models, reducing code duplication and improving data integrity. By shifting validation from controllers to models, we can:
*"Ardent lets us write self-validating Eloquent models, so validation rules live where they belong—in the model, not scattered across controllers or services. Here’s how we’d leverage it:
Validator::make() calls in controllers with model-level validation (e.g., if (!$user->save()) { return redirect()->back()->withErrors($user->errors); }).User::validateRules(['email' => 'required|unique:users'])).User) to demonstrate the reduction in boilerplate and share a PR template for adoption."**"Ardent adds a validateRules() method to Eloquent models, letting you define validation rules in the model itself. Example:
class User extends Ardent {
protected $rules = [
'name' => 'required|max:255',
'email' => 'required|email|unique:users',
];
public function validateRules($rules = []) {
$this->rules = array_merge($this->rules, $rules);
return parent::validateRules();
}
}
Why use it?
$user->errors).How can I help you explore Laravel packages today?