In laravel data is not inserting into database - laravel

I am new to laravel and doing project using laravel framework please help me to solve this problem.
data is not inserting into table.
routes.php
Route::post('report/save','TestingController#store');
TestingController
public function store(Request $request){
$userId = \Auth::user()->id;
$this->validate($request, [
'from_stk_loc' => 'required',
'testing_date' => 'required',
'casting_date' => 'required',
'debtor_no' => 'required',
'concrete_grade' => 'required',
'testing_age' => 'required',
]);
$test_details['client_id'] = $request->debtor_no;
$test_details['location'] = $request->from_stk_loc;
$test_details['casting_date'] = $request->casting_date;
$test_details['testing_date'] = $request->testing_date;
$test_details['concrete_grade'] = $request->concrete_grade;
$test_details['testing_age'] = $request->testing_age;
$test_details['report_date'] = date('Y-m-d');
$test_detailsId = DB::table('testing_report')->insert($test_details);
}
Model-> Testing.php
<?php
namespace App\Model;
use DB;
use Illuminate\Database\Eloquent\Model;
class Testing extends Model
{
protected $table = 'testing_report';
protected $fillable = [
'client_id',
'location',
'casting_date',
'testing_date',
'concrete_grade',
'testing_age',
];
}
Here is my form code, you can review this and find me a solution.
<div class="col-md-3">
<label for="exampleInputEmail1">{{ trans('message.testing.client') }}</label>
<select class="form-control select2" name="client_id" id="client_id">
<option value="all">Select client</option>
#foreach($customerData as $data)
<option value="{{$data->debtor_no}}">{{$data->name}}</option>
#endforeach
</select>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="examplefromlocation">{{ trans('message.form.from_location') }}</label>
<select class="form-control select2" name="from_stk_loc" id="from_stk_loc">
#foreach($locData as $data)
<option value="{{$data->loc_code}}" <?= ($data->inactive =="1" ? 'selected':'')?>>{{$data->location_name}}</option>
#endforeach
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>{{ trans('message.table.casting_date') }}<span class="text-danger"> *</span></label>
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input class="form-control" id="datepicker" type="text" name="casting_date">
</div>
<!-- /.input group -->
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>{{ trans('message.table.testing_date') }}<span class="text-danger"> *</span></label>
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input class="form-control" id="datepicker1" type="text" name="testing_date">
</div>
<!-- /.input group -->
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="examplefromlocation">{{ trans('message.form.gradeofconcrete') }}</label>
<input type="text" placeholder="{{ trans('message.form.gradeofconcrete') }}" class="form-control valdation_check" name="concrete_grade" value="">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="examplefromlocation">{{ trans('message.form.testing_age') }}</label>
<input type="text" placeholder="{{ trans('message.form.testing_age') }}" class="form-control valdation_check" name="testing_age" value="">
</div>
</div>
<div class="row">
<div class="col-md-12">
<!-- /.box-header -->
<div class="box-body no-padding">
<div class="table-responsive">
<table class="table table-bordered" id="purchaseInvoice">
<tbody>
<tr class="tbl_header_color dynamicRows">
<th width="5%" class="text-center">{{ trans('message.table.sno') }}</th>
<th width="10%" class="text-center">{{ trans('message.table.wt') }}</th>
<th colspan="2" width="10%" class="text-center">{{ trans('message.table.load') }}</th>
<th colspan="2" width="10%" class="text-center">Comp Strength in M. Pa</th>
<th width="15%" class="text-center">Avg Strength</th>
<th width="15%" class="text-center">{{ trans('message.table.remark') }}</th>
<th width="5%" class="text-center">{{ trans('message.table.action') }}</th>
</tr>
<tr class="tbl_header_color dynamicRows">
<th width="5%" class="text-center"></th>
<th width="10%" class="text-center"></th>
<th width="10%" class="text-center">{{ trans('message.table.machine') }}</th>
<th width="10%" class="text-center">{{ trans('message.table.calibrated') }}</th>
<th width="10%" class="text-center">7 Day's</th>
<th width="10%" class="text-center">27 Day's</th>
<th width="10%" class="text-center"></th>
<th width="15%" class="text-center"></th>
<th width="5%" class="text-center"></th>
</tr>
<tr class="custom-item"><td class="add-row text-danger"><strong>Add Custom Item</strong></td><td colspan="8"></td></tr>
</tbody>
</table>
</div>
<br><br>
</div>
</div>
<!-- /.box-body -->
<div class="col-md-12">
{{ trans('message.form.cancel') }}
<button type="submit" class="btn btn-primary btn-flat pull-right" id="btnSubmit">{{ trans('message.form.submit') }}</button>
</div>
</div>
</form>
Problem:
When I click submit button nothing is happening at all.
Any help would be highly appreciated.
This is view
<div class="col-md-3">
<label for="exampleInputEmail1">{{ trans('message.testing.client') }}</label>
<select class="form-control select2" name="client_id" id="client_id">
<option value="all">Select client</option>
#foreach($customerData as $data)
<option value="{{$data->debtor_no}}">{{$data->name}}</option>
#endforeach
</select>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="examplefromlocation">{{ trans('message.form.from_location') }}</label>
<select class="form-control select2" name="from_stk_loc" id="from_stk_loc">
#foreach($locData as $data)
<option value="{{$data->loc_code}}" <?= ($data->inactive =="1" ? 'selected':'')?>>{{$data->location_name}}</option>
#endforeach
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>{{ trans('message.table.casting_date') }}<span class="text-danger"> *</span></label>
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input class="form-control" id="datepicker" type="text" name="casting_date">
</div>
<!-- /.input group -->
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>{{ trans('message.table.testing_date') }}<span class="text-danger"> *</span></label>
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input class="form-control" id="datepicker1" type="text" name="testing_date">
</div>
<!-- /.input group -->
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="examplefromlocation">{{ trans('message.form.gradeofconcrete') }}</label>
<input type="text" placeholder="{{ trans('message.form.gradeofconcrete') }}" class="form-control valdation_check" name="concrete_grade" value="">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="examplefromlocation">{{ trans('message.form.testing_age') }}</label>
<input type="text" placeholder="{{ trans('message.form.testing_age') }}" class="form-control valdation_check" name="testing_age" value="">
</div>
</div>
<div class="row">
<div class="col-md-12">
<!-- /.box-header -->
<div class="box-body no-padding">
<div class="table-responsive">
<table class="table table-bordered" id="purchaseInvoice">
<tbody>
<tr class="tbl_header_color dynamicRows">
<th width="5%" class="text-center">{{ trans('message.table.sno') }}</th>
<th width="10%" class="text-center">{{ trans('message.table.wt') }}</th>
<th colspan="2" width="10%" class="text-center">{{ trans('message.table.load') }}</th>
<th colspan="2" width="10%" class="text-center">Comp Strength in M. Pa</th>
<th width="15%" class="text-center">Avg Strength</th>
<th width="15%" class="text-center">{{ trans('message.table.remark') }}</th>
<th width="5%" class="text-center">{{ trans('message.table.action') }}</th>
</tr>
<tr class="tbl_header_color dynamicRows">
<th width="5%" class="text-center"></th>
<th width="10%" class="text-center"></th>
<th width="10%" class="text-center">{{ trans('message.table.machine') }}</th>
<th width="10%" class="text-center">{{ trans('message.table.calibrated') }}</th>
<th width="10%" class="text-center">7 Day's</th>
<th width="10%" class="text-center">27 Day's</th>
<th width="10%" class="text-center"></th>
<th width="15%" class="text-center"></th>
<th width="5%" class="text-center"></th>
</tr>
<tr class="custom-item"><td class="add-row text-danger"><strong>Add Custom Item</strong></td><td colspan="8"></td></tr>
</tbody>
</table>
</div>
<br><br>
</div>
</div>
<!-- /.box-body -->
<div class="col-md-12">
{{ trans('message.form.cancel') }}
<button type="submit" class="btn btn-primary btn-flat pull-right" id="btnSubmit">{{ trans('message.form.submit') }}</button>
</div>
</div>
</form>

To store data I would give your html elements name as db field and use simple:
$testing = new Testing();
$testing->fill($request->all());
$testing->client_id = $request->your_client_id_from_source;
$testing->user_id = auth()->user()->id;
$testing->save();
So you will use directly laravel ORM and not raw db queries.

Your Model can only be used if your using Eloquent Queries. So based on your code your not using the model because your using Query Builder
I have 2 suggestions:
Check your date format "date('Y-m-d')" make sure that mysql allow this.
Change your $request->from_stk_loc to $request['from_stk_loc'] and the rest if the codes.
Try again, let me know if that helps.

First of all, I agree with everyone recommending Eloquent's ORM functionality over 'raw' DB queries.
As for a possible explanation: you are trying to insert into a non-fillable column: 'report_date', which might not be nullable in this table.
So try this in your model:
protected $fillable = [
'client_id',
'location',
'casting_date',
'testing_date',
'concrete_grade',
'testing_age',
'report_date'
];

Try this:
use App\Model\Testing;
public function store(Request $request){
$userId = \Auth::user()->id;
$validator = Validator::make($request->all(), [
'from_stk_loc' => 'required',
'testing_date' => 'required',
'casting_date' => 'required',
'debtor_no' => 'required',
'concrete_grade' => 'required',
'testing_age' => 'required',
]);
if( $validator->fails() )
{
return redirect()->back()->withInput()->withErrors($validator);
} else {
$testingObj = new Testing;
$testingObj->client_id = $request->client_id;
$testingObj->location = $request->location;
$testingObj->casting_date = $request->casting_date;
$testingObj->testing_date = $request->testing_date;
$testingObj->concrete_grade = $request->concrete_grade;
$testingObj->testing_age = $request->testing_age;
$testingObj->testing_age = $request->testing_age;
$testingObj->report_date = date('Y-m-d'); // try date('Y-m-d H:i:s') if datatype is datetime
$testingObj->save();
$test_detailsId = $testingObj->id;
}

Finally solved this problem by adding <input type="hidden" value="{{csrf_token()}}" name="_token" id="token"> in view page

please make sure in model fillable fields are respective field is mentioned ,correct with no extra space accurately. In your model you have not mentioned report_date field.
namespace App\Model;
use DB;
use Illuminate\Database\Eloquent\Model;
class Testing extends Model
{
protected $table = 'testing_report';
protected $fillable
= [
'client_id',
'location',
'casting_date',
'testing_date',
'concrete_grade',
'testing_age',
//add this to the end.
'report_date'
];

Related

How to redirect back to previous page after post request in laravel?

I have a system where user enters the date range from and to and gets all required data between that date range. Data retrieved from the database shows in the table containing checkbox to each row. When user Check the check box and submit the data it updates to the database, but I'm have to redirect to the same table after updating the data in database. It says the GET method is not supported for this route. Supported methods: POST. Need Help.
Here is my Date range fill view.
#extends('master')
#section('content')
<div class="input-group" style="margin:50px">
<table>
<form action="/payment_list_table" method="POST">
#csrf
<div class="form-outline">
<tr>
<th>
<label>From</label>
</th>
<th>
<input type="date" name= 'from' class="form-control" placeholder="Doc Received Date" required="" />
</th>
<th>
<label>To</label>
</th>
<th>
<input type="date" name= 'to' class="form-control" placeholder="Doc Received Date" required="" />
</th>
</tr>
<th>
<button type="submit" class="btn btn-success">
<i class="fas fa-search"></i>
</button>
</th>
</div>
</form>
</table>
</div>
#endsection
Here is my Search Table View
#extends('master')
#section('content')
<div class='container' style="margin-top:50px">
<div class="row">
<div class="input-group" style="margin:20px">
<form>
<table style="float:right">
<th>
<div class="form-outline">
<input type="search" id="form1" class="form-control" placeholder="Search"/>
</th>
</form>
</div>
<form method="POST">
#csrf
<button type="submit" formaction="#" name="submit" class="checklistpo">PO</button>
<button type="submit" formaction="#" name="submit" class="ajax.po">AO</button>
<div class="table-responsive">
<table class="table custom-table">
<thead>
<tr>
<th scope="col">
<label class="control control--checkbox">
<input type="checkbox" class="js-check-all"/>
<div class="control__indicator"></div>
</label>
</th>
<th scope="col" >S.N</th>
<th scope="col">LC NO</th>
<th scope="col">Applicant</th>
<th scope="col">Doc Value</th>
<th scope="col">Doc Received date</th>
<th scope="col">LC Type</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<?php $number = 1;?>
#foreach($datas as $items)
<tr>
<td><input type="checkbox" name="checkboxlist[]" value="{{$items->id}}" /></td>
<td>{{$number}}</td>
<td>{{$items->lc_no}}</td>
<td>{{$items->applicant}}</td>
<td>{{$items->doc_value}}</td>
<td>{{$items->rec_date}}</td>
<td>{{$items->sight_usance}}</td>
</tr>
<?php $number++; ?>
#endforeach
</tbody>
</table>
</div>
</form>
</div>
</div>
#endsection
Here is my Controller
function po(Request $req){
$validate=Validator::make($req->all(), [
"checkboxlist" => "required|array"
]);
foreach($req->checkboxlist as $list){
$data = Doc::find($list);
$data->payment_comment = "PO";
$data->Payment_status = "Prepared";
$data->save();
};
return Redirect::back();
if($validate->fails()){
return redirect()->back()->with("errors",$validate->errors());
}
}
And My Route
Route::post('po', [PaymentController::class, 'po']);
Your code needs a bit of formatting & make more understandable variables but anyways. You need to check if validation fails before foreach. return redirect()->back(); is the right way to go back.
function po(Request $req)
{
$validate = Validator::make($req->all(), [
"checkboxlist" => "required|array"
]);
if ($validate->fails()) {
return redirect()->back()->with("errors", $validate->errors());
}
foreach ($req->checkboxlist as $list) {
$data = Doc::find($list);
$data->payment_comment = "PO";
$data->Payment_status = "Prepared";
$data->save();
}
return redirect()->back();
}

Add user email addresses separated by commas in Laravel

I want to add the selected users to a separate table from the list of all users. Similar to the Trello feature, just # and tag their name. I have no idea what to write this function. Any ideas?
This is the form on my interface, and I do not know what to do next in the controller and the form block.
<div class="tab-pane fade" id="group-add-members" role="tabpanel">
<div class="users-manage" data-filter-list="form-group-users">
<div class="mb-3">
<div class="form-group row">
<textarea class="form-control col" name="group-description"
placeholder="Add users by email, each email separated by
commas
e.g: matt#.edu.com, joe#edu.com" rows="3">
</textarea>
</div>
<div class="row align-items-center">
<div class="col">
<button class="btn btn-outline-primary" type="button">
<i class="fad fa-user-plus"></i>Add</button>
<span>   or   </span>
</div>
<div class="d-none d-md-block col-4 col-lg-5 text-right">
</div>
</div>
<div class="row align-items-center mt-2">
<div class="d-block d-md-none d-sm-block ml-2">
</div>
</div>
</div>
<hr>
<h6>Member info</h6>
<div class="row justify-content-center">
<div class="table-responsive mt-3">
<table class="stripe" id="example" style="width:100%">
<thead>
<tr>
<th></th>
<th class="text-left">Full name</th>
<th class="text-left">Email</th>
<th class="text-left">Student ID</th>\
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td class="text-left">My name</td>
<td class="text-left">qnv164#edu.com</td>
<td class="text-left">123456789</td>
<td>
<span class="ic-dark"><i class="fad fa-trash-alt"></i></span>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<th></th>
<th class="text-left">Full name</th>
<th class="text-left">Email</th>
<th class="text-left">Student ID</th>
<th>Action</th>
</tr>
</tfoot>
</table>
</div>
<!-- end div table responsive -->
</div>
<!-- end div row -->
</div>
</div>
{{ profile->description ?? 'Not Available' }}

Form Input Bindings v-model not rendering in a views page in laravel

I have question on it for the vue.js I already have a library vue.js in my web application site. Now my problem is when i try to use the Form Input Bindings the v-model this line of code here below
<input v-model="message" placeholder="edit me">
<p>Message is: {{ message }}</p>
what i notice is it says
Use of undefined constant test - assumed 'test'
So i try to see the solution on this one by adding a # beacuase laravel is using blade template. Now when i add a # the error is gone but the render goes this way {{ test }} . Why does it not rendered correctly in my browser?. Can someone help me figured this thing out?. Any help is muchly appreciated. TIA.
Here is my code
#extends('layouts.app')
#section('title', 'Cases New Invoice | RMTG')
#section('content')
<div id="content-wrapper">
<div class="container-fluid">
<!-- Breadcrumbs-->
<ol class="breadcrumb">
<li class="breadcrumb-item">
Dashboard
</li>
<li class="breadcrumb-item active">Cases New Invoice</li>
</ol>
<div class="row">
<div class="col-lg-12">
<div class="card mb-3">
<div class="card-header">
<i class="fa fa-file"></i>
New Invoice</div>
<div class="card-body">
<div class="form-group">
<div class="form-row">
<div class="col-md-6" >
<div class="table-responsive">
<form action="" method="post">
{{ csrf_field() }}
<table class="table table-bordered" width="100%" cellspacing="0">
<thead>
<tr>
<th width="150px;">Contact Name: </th>
<td>{{ $opp->contacts }}</td>
</tr>
<tr>
<th>Case Number:</th>
<td>OPP -{{ $opp->code }}</td>
</tr>
<tr>
<th>Case Name:</th>
<td>{{ $opp->tax_year }}</td>
</tr>
<tr>
<th>Item Code:</th>
<td>
<div id="app-item">
<select name="itemCode" class="form-control">
<option v-for="item in items" v-bind:value="item.value">
#{{ item.text }}
</option>
</select>
</div>
</td>
</tr>
<tr>
<th>Notes: </th>
<td>
<input type="text" name="notes" class="form-control" />
</td>
</tr>
<tr>
<th>Amount: </th>
<td><input v-model="test" type="text" name="amount" class="form-control" required />
</td>
</tr>
<tr>
<th>VAT 20% Amt: </th>
<td>
<input type="text" name="vatAmount" class="form-control" />
</td>
</tr>
<tr>
<th>Total Amount: </th>
<td>
<input type="text" name="totalAmount" class="form-control" />
</td>
</tr>
</thead>
</table>
<div class="pull-right">
<button type="submit" class="btn btn-success">
<i class="fa fa-save" aria-hidden="true" style="font-size:24px"></i> Save
</button>
</div>
</form>
</div>
</div>
<div class="col-md-6" >
<h3>Amount Due: £ #{{ test }}</h3>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
//Item code
new Vue({
el: '#app-item',
data: {
items:[
{ text:'Tax Returns', value: 'Tax Returns' },
{ text:'UTR Filing', value: 'UTR Filing'}
]
}
})
</script>
#endsection

I have a problem with my laravel pagination

I am new to Laravel. I am trying to create pagination with the data in my bootstrap table.
This is my index Controller function:
$Courses=Courses::orderBy('name','desc')->paginate(1);
return view('Courses.index')->with('Courses',$Courses);
I am getting this error:
Call to undefined method App\Courses::links() (View:
C:\laragon\www\TharakaCollege\resources\views\Courses\index.blade.php)
The information provided is not enough, however I think the problem is in your view. You have to have a code like this in your blade file:
<div class="pages">
<ul class="pagination ">
<li>{{$Courses->appends(request()->query())->links()}}</li>
</ul>
</div>
Moreover you'd better edit your returning view like this:
return view('Courses.index', array('Courses'=> $Courses));
This is the code in Courses/index.blade.php
<div id="page-wrapper">
#include('includes.message');
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="row">
<div class="col-lg-12">
<div class="panel panel-info">
<div class="panel-heading">
Courses
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<div class="table-responsive">
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th class="text-center">#</th>
<th class="text-center"> code</th>
<th class="text-center">Course Name</th>
<th class="text-center">Category</th>
<th class="text-center">Requirements</th>
</tr>
</thead>
<tbody>
#if(count($Courses)>0)
#foreach($Courses as $Courses)
<tr class="item{{$Courses->id}}">
<td>{{$Courses->id}}</td>
<td>{{$Courses->code}}</td>
<td>{{$Courses->name}}</td>
<td>{{$Courses->category}}</td>
<td>{{$Courses->requirements}}</td>
<td><a class="btn btn-info btn-sm" href="/Courses/{{$Courses->id}}/edit">Edit</a>
</td>
<td>
<form method="POST" action="{{route('Courses.destroy',$Courses->id)}}">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="hidden" name="_method" value="DELETE">
<input type="submit" class="btn btn-danger btn-sm" value="Delete">
</form>
</td>
</tr>
#endforeach
#else
<p>No Courses</p>
#endif
</tbody>
</table>
{{ $Courses->links() }}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
You should try this:
<div class="pull-left">
<div class="row">
<div class="col-xs-12">
<div class="explore-pagination">
<nav>
<div class="pagination"> {{ $Courses->render() }}</div>
</nav>
</div>
</div>
</div>
</div>
Try this code instead (modified version of yours):
<div id="page-wrapper">
#include('includes.message');
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="row">
<div class="col-lg-12">
<div class="panel panel-info">
<div class="panel-heading">
Courses
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<div class="table-responsive">
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th class="text-center">#</th>
<th class="text-center"> code</th>
<th class="text-center">Course Name</th>
<th class="text-center">Category</th>
<th class="text-center">Requirements</th>
</tr>
</thead>
<tbody>
#if(count($Courses)>0)
#foreach($Courses as $Course)
<tr class="item{{$Course->id}}">
<td>{{$Course->id}}</td>
<td>{{$Course->code}}</td>
<td>{{$Course->name}}</td>
<td>{{$Course->category}}</td>
<td>{{$Course->requirements}}</td>
<td><a class="btn btn-info btn-sm" href="/Courses/{{$Course->id}}/edit">Edit</a>
</td>
<td>
<form method="POST" action="{{route('Courses.destroy',$Course->id)}}">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="hidden" name="_method" value="DELETE">
<input type="submit" class="btn btn-danger btn-sm" value="Delete">
</form>
</td>
</tr>
#endforeach
#else
<p>No Courses</p>
#endif
</tbody>
</table>
{{$Courses->appends(request()->query())->links()}}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I have modified your foreach loop as well as ->links().
When calling the paginate method, you will receive an instance of Illuminate\Pagination\LengthAwarePaginator. In addition to these helpers methods, the paginator instances are iterators and may be looped as an array. So, once you have retrieved the results, you may display the results and render the page links using Blade:
Your blade should contain:
<div class="container">
#foreach ($courses as $course)
{{ $course->fieldName }}
#endforeach
</div>
{{ $courses->links() }}

How to get sum score when checked the checkboxess?

I have score field in table of infractions. And I have many checkboxes. When I checked thed chechboxes, The total of scores are collected with ajax.
<div id="collapse6" class="panel-collapse collapse">
<div class="panel-body">
<div class="table-responsive">
<table class="table table-bordered">
#foreach($infractions as $infraction)
<tr>
<th>{{ $infraction->title }}</th>
<td>
<input type="hidden" name="infractions[{{ $infraction->id }}]" value="0" >
<input type="checkbox" value="1" onclick="{{ $infraction->score }}" name="infractions[{{ $infraction->id }}]" data-toggle="toggle">
</td>
</tr>
#endforeach
</table>
</div>
<div class="text-right"> Totlal
<span id="total">
</span>
</div>
</div>
</div>
Ajax
function scorePlus (id)
{
// var value = parseInt(document.getElementById('num'+id).value, 10);
value = isNaN(value) ? 0 : value;
value++;
document.getElementById('total').value = value;
}

Resources