Extending Daalder
As Daalder is built on top of Laravel, it benefits from all the advantages of Laravel's built-in IoC implementation.
Therefore, extending Daalder relies strongly upon service bindings. If, for instance, your e-commerce project needs customized validation logic, you can easily add new validation rules by:
- creating rules that implement the `Pionect\Backoffice\Http\Validators\Validates` contract or
- extending the `Validator` facade within your project-specific service provider:
// CustomRule.php
use Pionect\Backoffice\Http\Validators\Validates;
class CustomRule implements Validates
{
public function validate($attribute, $value, array $parameters)
{
// your validation logic
}
}
// YourServiceProvider.php
use Illuminate\Support\ServiceProvider;
class YourServiceProvider extends ServiceProvider
{
public function boot()
{
Validator::extend('custom_rule', CustomRule::class . '@validate');
}
}
This approach applies to all cases of extending the core-level Daalder features. This allows keeping the core logic untouched, which in turn, will allow you to easily revert extensions, if they are no longer required.