Sorry Im new to Laravel and trying to save to the database for the first time. Im trying to save an array to the database but the error "array to string conversion" is appearing. I've tried changing the string value in the migration file to other options but the same error is appearing.
Controller
public function store(Request $request)
{
Myroutes::create([ //posting to acc table
'start' => $request->start,
'end' => $request->end,
'waypoints' => $request->waypoints
]);
return redirect('/');
}
migration
public function up()
{
Schema::create('myroutes', function (Blueprint $table) {
$table->increments('myroute_id');
$table->integer('user_id');
$table->string('start');
$table->string('end');
$table->string('waypoints');
$table->timestamps();
});
}
model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Myroutes extends Model
{
protected $fillable = [
'user_id',
'start',
'end',
'waypoints'
];
}
View
<div id="dynamicInput" class="form-group">
<label>Additional Destinations</label>
<input type="text" name="waypoints[]" class="form-control" autocomplete="on">
</div>
Database table
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2HUtcE7
via IFTTT
Aucun commentaire:
Enregistrer un commentaire