I created an expense form in Laravel and tried to submit it for the data to be inserted into the database but after submitting this error got displayed:
"Trailing data"
I have tried all the possible ways I knew I could even searched through the net still couldn't find a solution to this problem.
I have been on it for the past hours.
Here is the create.blade
<div class="portlet light bordered">
<h3 class="page-title">Expenses</h3>
{!! Form::open(['method' => 'POST', 'url' => ['admin/save']]) !!}
<div class="panel panel-default">
<div class="panel-heading">
Create
</div>
<div class="panel-body">
<div class="row">
<div class="col-xs-12 form-group">
{!! Form::label('expenses_category_id', 'Expense Category*', ['class' => 'control-label']) !!}
{!! Form::select('expenses_category_id', $expenses_categories, old('expenses_category_id'), ['class' => 'form-control']) !!}
<p class="help-block"></p>
@if($errors->has('expenses_category_id'))
<p class="help-block">
</p>
@endif
</div>
</div>
<div class="row">
<div class="col-xs-12 form-group">
{!! Form::label('entry_date', 'Entry date*', ['class' => 'control-label']) !!}
{!! Form::text('entry_date', old('entry_date'), ['class' => 'form-control date dpicker', 'placeholder' => '']) !!}
<p class="help-block"></p>
@if($errors->has('entry_date'))
<p class="help-block">
</p>
@endif
</div>
</div>
<div class="row">
<div class="col-xs-12 form-group">
{!! Form::label('amount', 'Amount*', ['class' => 'control-label']) !!}
{!! Form::text('amount', old('amount'), ['class' => 'form-control', 'placeholder' => '']) !!}
<p class="help-block"></p>
@if($errors->has('amount'))
<p class="help-block">
</p>
@endif
</div>
</div>
</div>
</div>
{!! Form::submit('Save', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
</div>
The ExpensesController
public function store(StoreExpensesRequest $request)
{
Expense::create($request->all());
return redirect('admin/expenses');
}
the web.php
Route::post('/save', 'ExpensesController@store');
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire