Tuesday, April 11, 2017

can we add properties on request in laravel

I want to use single validate for birthday year, birth month, birth day as birthday for registration in laravel 5.4 here is my code

public function register(Request $request)
{
    // here i want to add bithday input on reqeust but nothing happen
    $request->birthday = implode('-', array(
            $request->birth_year,
            $request->birth_month,
            $request->birth_date
        ));

    $this->validator($request->all())->validate();

    event(new Registered($user = $this->create($request->all())));

    return redirect()->back()->with('info', 'User successfully registered');
}

nothing happen with that code, I can validate those 1 by 1 using date_format. the problem is what if the user select February and day is 31



via white-comet

Advertisement