laravel-ardent / ardent

Self-validating, secure and smart models for Laravel's Eloquent ORM
BSD 3-Clause "New" or "Revised" License
1.39k stars 211 forks source link

Fighting spam comments #233

Open stlouisweb opened 10 years ago

stlouisweb commented 10 years ago

Is there a preferred or built-in way of combating spam comments when validating forms with Ardent? I've tried to use https://github.com/msurguy/Honeypot with the valdation rules in my model and the my_time field won't pass validation.

heavysumo commented 9 years ago

You just need to set the additional purge fields e.g.

function __construct($attributes = array()) {
  parent::__construct($attributes);
  $this->purgeFilters[] = function($key) {
    $purge = array('my_time', 'my_name');
    return ! in_array($key, $purge);
  };
}

Also put them in your fillable property:

protected $fillable = array('my_time', 'my_name', ..........);

This did the trick for me.