Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Titoratus/4b76c9581779f72ea84f91b0ac282985 to your computer and use it in GitHub Desktop.
Save Titoratus/4b76c9581779f72ea84f91b0ac282985 to your computer and use it in GitHub Desktop.
[OctoberCMS] Валидация нескольких полей за один раз
use \October\Rain\Exception\ValidationException;
class myModel extends Model
{
public function beforeSave()
{
// date_in, date_out - поля с датами!
$start = $this->date_in;
$end = $this->date_out;
$check = Db::table('mytable')
->whereBetween('myColumn', [$start, $end])
->get();
if ($check->count() > 0)
throw new ValidationException(['date_in' => 'My error message.']);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment