からの挿入選択した複数の値Iがlaravel 5フォーム
@extends('users.home')
@section('content')
<form role="form" action="{{route('postPay')}}" method="post">
<div class="row">
<div class="col-md-12">
<fieldset class="group-border">
<legend class="group-border">Payment Record</legend>
<div class="row">
<div class="col-lg-4">
<div class="form-inline">
<label class="control-label">Current Date:</label>
<input type="text" class="date form-control" id="datepicker" name="date">
</div>
</div>
<div class="col-lg-4">
<div class="form-inline">
<!-- <label class="control-label">Month:</label> -->
<select style="width:250px" multiple="true" class="form-control input-md" id="js-example-basic-single" name="month">
<option value="january">January</option>
<option value="february">February</option>
<option value="march">March</option>
<option value="april">April</option>
<option value="may">May</option>
<option value="june">June</option>
<option value="july">July</option>
<option value="august">August</option>
<option value="september">September</option>
<option value="october">October</option>
<option value="november">November</option>
<option value="december">December</option>
</select>
</div>
</div>
<div class="col-lg-4">
<div class="form-inline">
<label class="control-label">Year:</label>
<input class="form-control input-md" type="text" name="year">
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-lg-1">
<label for="">Customer</label>
</div>
<div class="col-lg-7">
<select class="form-control input-md" name="record_id">
@foreach($records as $record)
<option value="{{$record->id}}">{{$record->user_name}}</option>
@endforeach
</select>
</div>
<div style="float: left;" class="col-lg-4 text-left">
<div class="form-inline">
<label class="control-label">Due: </label>
<input class="form-control input-sm" type="text" name="due">
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-lg-1">
<label class="control-label">Amount:</label>
</div>
<div class="col-lg-7">
<input class="form-control input-sm" type="text" name="amount">
</div>
<div class="col-lg-4">
<div class="form-inline">
<label class="control-label">Advance:</label>
<input class="form-control input-sm" type="text" name="advance">
</div>
</div>
</div>
</fieldset>
</div>
</div>
<div class="box-footer">
<button type="submit" class="btn btn-success btn-block">Submit</button>
</div>
<input type="hidden" name="_token" value="{{Session::token()}}"/>
</form>
@endsection
以下のようlaravel 5でフォームを持っており、これは支払移行テーブルで、フォームで
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePaymentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('payments', function (Blueprint $table) {
$table->increments('id');
$table->integer('record_id')->unsigned();
$table->date('date');
$table->string('month');
$table->integer('year');
$table->integer('amount');
$table->integer('advance');
$table->integer('due');
$table->dateTime('created_at');
$table->dateTime('updated_at');
$table->foreign('record_id')->references('id')->on('records');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('payments');
}
}
「月」フィールドデータベースに保存したいselect2で作成された複数の選択フィールドですが、データベースの各レコードが複数の値を許可していない限り、どのように動作させることができますか?助けてください。
ありがとうございます.. :) –
私は同じ方法を使用し、それは素晴らしい動作します! –