Andrew Vanusi Andrew Vanusi - 1 month ago 11
PHP Question

How to save checkbox value to database Laravel

here's my form code :

<div class="form-group">
<label>Warranty:</label>
{{ Form::checkbox('warranty', 0, false) }}
</div>


here's my controller code :

public function save(Request $request, $obj = null) {

if (!$obj) {
$obj = new Service;
}
(Input::has('warranty')) ? true : false;
return $this->saveHandler($request, $obj);
}


it throws this error Class 'App\Http\Controllers\Input' not found

any idea ?

Answer

You can use request object to get the warranty input as:

$request->get('warranty')

or

$request->has('warranty')