Reputation: 499
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 ?
Upvotes: 2
Views: 12954
Reputation: 591
$request->merge(array('checkbox_name' => $request->has('checkbox_name') ? true : false));
Object::create($request->all());
This is how I save boolean parameters which are checkboxes in form.
Or simply give your checkbox value
{{ Form::checkbox('checkbox_name', 1) }}
Upvotes: 3
Reputation: 163748
Input
facade was removed in latest verison, so you can add it to config/app.php
:
'Input' => Illuminate\Support\Facades\Input::class,
Or add this line to the beginning of a controller:
use Illuminate\Support\Facades\Input;
Or write full path when you use it:
(\Illuminate\Support\Facades\Input::has('warranty')) ? true : false;
Upvotes: 1
Reputation: 17658
You can use request
object to get the warranty
input as:
$request->get('warranty')
or
$request->has('warranty')
Upvotes: 5
Reputation: 611
Add this at top in the controller,
use Illuminate\Support\Facades\Input;
Upvotes: 1