I have made the following migration in Laravel:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class QualityCheckTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('quality_check', function (Blueprint $table) {
$table->increments('id');
$table->boolean('favicon');
$table->boolean('title');
$table->boolean('image-optimization');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('quality_check');
}
}
I have the following controller method that runs when the form in the frontEnd is submitted:
public function store(CreateArticleRequest $request) {
// $input = Request::all();
Article::create($request->all());
return redirect('articles');
}
My form looks like , so:
{!! Form::open([ 'action' => 'QualityCheckController@validateSave' , 'class'=>'quality-check-form' , 'method' => 'POST' ]) !!}
<div class="input-wrpr">
{!! Form::label('favicon', 'Favicon') !!}
{!! Form::checkbox('favicon', 'value' ); !!}
</div>
<div class="input-wrpr">
{!! Form::label('title', 'Page Title') !!}
{!! Form::checkbox('title', 'value'); !!}
</div>
<div class="input-wrpr">
{!! Form::label('image-optimization', 'Image Optimization') !!}
{!! Form::checkbox('image-optimization', 'value'); !!}
</div>
{!! Form::submit('Click Me!') !!}
{!! Form::close() !!}
So when the method runs the values of the checkboxes are saved to the database.
As of now , all entries are showing as 0
, Like so:
Now how to make it such that when the checkbox is checked , 1
is saved and when the checkbox is left unchecked the value in is left at 0
??