I am using this in my controller to grab all of the input data from the form, however only two out of the three inputs are actually inserting into their database tables, the last one just remains empty?
Controller method:
$something->create($request->all());
And the form:
{!! Form::open(['route' => 'songs.store', 'method' => 'PATCH']) !!}
<div class="form-group">
{!! Form::label('title', 'Title:') !!}
{!! Form::text('title', null, ['class' => 'form-control', 'placeholder' => 'The name of the song']) !!}
</div>
<br />
<div class="form-group">
{!! Form::label('lyrics', 'Lyrics:') !!}
{!! Form::textarea('lyrics', null, ['class' => 'form-control', 'placeholder' => 'Lyrics that belong to the song']) !!}
</div>
<br />
<div class="form-group">
{!! Form::label('slug', 'Slug:') !!}
{!! Form::text('slug', null, ['class' => 'form-control', 'placeholder' => 'Specify a slug to use for the song']) !!}
</div>
<div class="form-group">
{!! Form::submit('Update records', ['class' => 'btn btn-primary']) !!}
</div>
{!! Form::close() !!}
create method only accepts fields you defined in the model. check the $fillable array. http://laravel.com/docs/4.2/eloquent#mass-assignment
astroanu said:
create method only accepts fields you defined in the model. check the $fillable array. http://laravel.com/docs/4.2/eloquent#mass-assignment
The fillable array is already set to this:
class Song extends Eloquent{
public $timestamps = false;
protected $fillable = [
'title', 'lyrics', 'slug'
];
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community