Never tried it myself, but just googled and found:
Request::merge(['New Key' => 'New Value']);
So you can try:
Request::merge(['hostname' => $hostname]);
Hello guys! I'm trying to find out how I can manipulate the request data from a form prior to saving it to the database. For instance I have a form that has a field for hostname. This field is disabled as the value is being pulled directly from the $_SERVER superglobal gethostbyaddr($_SERVER['REMOTE_ADDR']. Since it is disabled this field does not submit with the form, which is fine. I know I can create a hidden input field with the same value which does work, though it is not secure. Jeffrey Way even stated in his screencast he recommends against doing this.
In the same video he made it seem like I could just assign the value to the request variable like so:
...
...
public function store(Request $request)
{
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$request->hostname = $hostname;
Systems::create($request->all());
}
Unfortunately this does not work as the $request variable does not show the hostname.
Additionally if I can get this to work then I can use some of the laravel validation rules to make sure that this value is unique in the database. Since hostname is not being found in the $request variable the validation will never work.
Does anyone have an idea on how to get this to work?
Never tried it myself, but just googled and found:
Request::merge(['New Key' => 'New Value']);
So you can try:
Request::merge(['hostname' => $hostname]);
Please or to participate in this conversation.