Reputation: 385
I am creating a project in Laravel. In updatepackage.blade.php
a user checked a checkbox. The checkbox row values are then stored into database and sent to another view called printpackage.blade.php
.
Here the problem starts. When the user refreshes the page, values shown in entries are automatically inserted into database. I don't know how to stop this.
updatepackage.blade.php
<td align='center'>{{$i}}</td>
<td><input type='text' name="meter[]" readonly value="{{$item['passmts']}}" ></td>
<td><input type='text' name="points[]" readonly value="{{$item['points']}}"></td>
<td><input type='text' name="pts[]" readonly value="{{$item['pts']}}"></td>
<td><input type="checkbox" name="ids[]"value="{{$i}}" /></td>
clientcontroller.php
$insert=DB::table('packageroll')->insert(array(Input::all()));
$tc=\Input::get('tc');
$construction=\Input::get(construction');
$table1= DB::table('packageroll')->where('tc','=',$tc)->where('construction','=',$construction)->get();
return \View::make('dashboard.vendor.printpackage')->with('table1',$table1);
printpackage.blade.php
<td><input type='text' name='meter[]' value="{{$item['meter']}}" ></td>
<td><input type='text' name='points[]' value="{{$item['points']}}"></td>
<td><input type='text' name='pts[]' value="{{$item['pts']}}"></td>
Upvotes: 4
Views: 1522
Reputation: 4826
Hey you can use different validation for store and update carefull if you have unique value below i have mention how to handle
public function store(Request $request)
{
$this->validate($request, ['code'=>'required|unique:consignees,''=>'',''=>'']);
}
public function update(Consignee $consignee,Request $request)
{
$this->validate($request,['code'=>'required|unique:consignees,code,'.$consignee->id,''=>'',''=>'']);
}
Upvotes: 2