Have been trying to get a html <input type="number" to be stored as an integer. (for money stored as cents)
https://laracasts.com/discuss/channels/laravel/how-to-convert-my-input-to-integer this post shows a number of techniques. I tried type casting in the model.
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'bid' => 'integer',
];
This generates the array given error. However, when it's commented out, the error still persists.
Argument 2 passed to Symfony\Component\HttpFoundation\RedirectResponse::__construct() must be of the type int, array given
here's the full error, I found a post on github about trust proxies, but the version I have includes that (5.8).
protected $headers = Request::HEADER_X_FORWARDED_ALL;
I gave this below a shot, but it too gives the error.
public function store(Job $job)
{
$this->validate(request(), [
'bid' => 'required|integer|min:2'
]);
$bid = (int) request('bid');
// add bid to job
$bid = auth()->user()->bids()->create([
'bid' => $bid,
'job_id' => $job->id
]);
...
It seems like such a basic thing but I must have something out of skew.
How have you solved this?