I am attempting to have a input field for adding a website/url. All I want to require to successfully submit the form is www.domainname.com; however, after submission I want to add back on http:// or https:// if it was not added by the person submitting the form.
The validation is along the lines of the following,
public function name($id) {
$input = Input::all();
$validator = Validator::make(
$input,
array(
'website' => 'active_url',
)
);
}
For this to work an if statement is needed. I have tried inserting something along the lines of the code listed below, but have not had any luck.
if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {
$url = "http://" . $url;
}
I am fairly new to PHP and just starting to use Laravel, so I apologize in advance if there is any confusion or lack of information. Any help is appreciated.