今天统治之前的拉拉维尔...怎么做

2022-08-30 19:23:39

对于此规则,我收到错误syntax error, unexpected '.', expecting ')'

public static $rules = array(
    'first_name' => 'required|alpha-dash',
    'last_name' => ' required|alpha-dash',
    'media_release' => 'required|boolean',
    'birthday' => 'before:' . date('Y-m-d')

);

我不明白为什么这行不通。我正在运行 Laravel 4.2.12


答案 1

试试这个:

'birthday' => 'date_format:Y-m-d|before:today',

再见


答案 2

仅供未来用户使用:

Laravel 5 使用表单请求:

'birthday' => 'before:today',    // Doesn't accept today date
'birthday' => 'before:tomorrow', // Accept today date

推荐