I did the following migration to Laravel:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class QualityCheckTable extends Migration
{
public function up()
{
Schema::create('quality_check', function (Blueprint $table) {
$table->increments('id');
$table->boolean('favicon');
$table->boolean('title');
$table->boolean('image-optimization');
});
}
public function down()
{
Schema::drop('quality_check');
}
}
I have the following controller method that starts when a form is submitted in frontEnd:
public function store(CreateArticleRequest $request) {
Article::create($request->all());
return redirect('articles');
}
My form looks like this:
{!! 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 starts, the values of the flags are stored in the database.
At the moment, all entries are displayed as 0. For instance:

Now, how to make it so that when the checkbox is checked, it is 1saved, and if the checkbox is not checked, the value in remains in 0??
source
share