Hi,
i have a problem, and i already search for the solution, but the problem is that none of the solutions work for me... The error what i get.
MassAssignmentException in Model.php line 444: _token
All i want is save the results from the form to the database....
the code form web.php
Route::get('admin', 'AdminController@index');
Route::get('admin/bedrijven/overzicht/', 'AdminController@overzicht');
Route::get('admin/bedrijven/{id}/', 'AdminController@view');
AdminController.php
public function save(Request $request, $id)
{
$bedrijven = Bedrijven::findOrFail($id);
$bedrijven->update(Request::all());
dd($bedrijven);
}
edit.blade.php
@extends('layout')
@section('content')
<div class="content-wrap">
<div class="container clearfix">
<form id="edit-form" name="edit-form" class="nobottommargin" action="/admin/bedrijven/edit/{{ $bedrijven->id }}" method="post">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="col_half">
<label for="edit-form-naam">Naam:</label>
<input type="text" id="edit-form-naam" name="edit-form-naam" value="{{ $bedrijven->naam }}" class="form-control" />
</div>
<div class="col_half">
<label for="edit-form-slug">Slug:</label>
<input type="text" id="edit-form-slug" name="edit-form-slug" value="{{ $bedrijven->slug }}" class="form-control" />
</div>
<div class="clear"></div>
<div class="col_full nobottommargin">
<button class="button button-3d button-black nomargin" id="edit-form-submit" name="edit-form-submit" value="edit">Opslaan</button>
</div>
</form> </div>
</div>
@endsection
admin.php // Model
<?php
namespace App;
use Eloquent\Model;
use App\Bedrijven;
use App\Openingstijden;
use App\Ervaringen;
use Form;
use Carbon\Carbon;
class Admin extends Model
{
protected $table = 'bedrijvens';
protected $guarded = array();
}
Because you have $guarded as an empty array you are saying that its ok to write the whole of the request data into the database.
csrf token _token
is one of the fields in the $request and so an attempt is made to write it to the database.
options;
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community