只有created_at和Updated_at列接受我新创建的voyager laravel数据库表中的数据

时间:2017-05-23 15:36:27

标签: php mysql laravel laravel-5 voyager

我使用voyager数据库菜单添加一个新表。问题是我无法使用我新创建的数据库创建新数据...任何时候我尝试插入新数据时,只会填充已填充的created_at和Updated_at列

和代码:

<form clas[s="form-edit-add" role="form"][1]
      action="@if(isset($dataTypeContent->id)){{
    route('voyager.'.$dataType->slug.'.update', $dataTypeContent->id) }}@else{{ 
    route('voyager.'.$dataType->slug.'.store') }}@endif"
      method="POST" enctype="multipart/form-data">
    <!-- PUT Method if we are editing -->
@if(isset($dataTypeContent->id))
    {{ method_field("PUT") }}
@endif

<!-- CSRF TOKEN -->
    {{ csrf_field() }}

    <div class="panel-body">
        <div class="form-group">
            <label for="name">Staff_id</label>
            <input type="text" class="form-control"
                   name="Staff_id"
                   placeholder="Staff_id" id="Staff_id"
                   value="@if(isset($dataTypeContent-
    >Staff_id)){{ old('Staff_id', $dataTypeContent->Staff_id) 
    }}@else{{old('Staff_id')}}@endif">
        </div>
        <div class="form-group">
            <label for="name">Title</label>
            <input type="text" class="form-control"
                   name="title"
                   placeholder="title" id="title"
                   value="@if(isset($dataTypeContent-
     >title)){{ old('title', $dataTypeContent->title) 
     }}@else{{old('title')}}@endif">
        </div>

        div class="form-group">
        <label for="name">First_Name</label>
        <input type="text" class="form-control"
               name="first_name"
               placeholder="first_name" id="first_name"
               value="@if(isset($dataTypeContent-
      >first_name)){{ old('first_name', $dataTypeContent->first_name) 
       }}@else{{old('first_name')}}@endif">
    </div>
    <div class="form-group">
        <label for="name">Middle_Name</label>
        <input type="text" class="form-control"
               name="middle_name"
               placeholder="middle_Name"
               id="middle_name"
               value="@if(isset($dataTypeContent-
         >middle_name)){{ old('middle_name', $dataTypeContent->middle_name) 
         }}@else{{old('middle_name')}}@endif">
    </div>
    <div class="form-group">
        <label for="name">Last_Name</label>
        <input type="text" class="form-control"
               name="last_name"
               placeholder="Last_Name" id="last_name"
               value="@if(isset($dataTypeContent-
       >last_name)){{ old('last_name', $dataTypeContent->last_name) 
       }}@else{{old('last_name')}}@endif">
    </div>


    <div class="form-group">
        <label for="name">Gender</label>
        <input type="text" class="form-control"
               name="gender"
               placeholder="gender" id="gender"
               value="@if(isset($dataTypeContent-
         >gender)){{ old('gender', $dataTypeContent->gender) 
         }}@else{{old('gender')}}@endif">
    </div>

    <div class="form-group">
        <label for="name">DOB</label>
        <input type="text" class="form-control"
               name="dob"
               placeholder="dob" id="dob"
               value="@if(isset($dataTypeContent->dob))
               {{ old('dob', $dataTypeContent->dob) }}@else{{old('dob')}}@endif">
    </div>

    <div class="form-group">
        <label for="name">Phone_Number</label>
        <input type="text" class="form-control"
               name="phone_number"
               placeholder="phone_number"
               id="phone_number"
               value="@if(isset($dataTypeContent-
          >phone_number)){{ old('phone_number', $dataTypeContent->phone_number) 
          }}@else{{old('phone_number')}}@endif">
    </div>

    <div class="form-group">
        <label for="name">Unit</label>
        <input type="text" class="form-control"
               name="unit"
               placeholder="unit" id="unit"
               value="@if(isset($dataTypeContent->unit))
               {{ old('unit', $dataTypeContent->unit)
             }}@else{{old('unit')}}@endif">
    </div>


    <div class="form-group">
        <label for="name">Department</label>
        <input type="text" class="form-control"
               name="department"
               placeholder="department" id="department"
               value="@if(isset($dataTypeContent-
             >department)){{ old('department', $dataTypeContent->department) 
           }}@else{{old('department')}}@endif">
    </div>
    <div class="form-group">
        <label for="name">Company</label>
        <input type="text" class="form-control"
               name="company"
               placeholder="company" id="company"
               value="@if(isset($dataTypeContent-
                >company)){{ old('company', $dataTypeContent->company) 
                 }}@else{{old('company')}}@endif">
    </div>


    <div class="form-group">
        <label for="name">Employment_status</label>
        <input type="text" class="form-control"
               name="employment_status"
               placeholder="employment_status"
               id="employment_status"
               value="@if(isset($dataTypeContent-
              >employment_status)){{ old('employment_status', $dataTypeContent-
           >employment_status) }}@else{{old('employment_status')}}@endif">
    </div>


    <div class="form-group">
        <label for="name">Guarantor1</label>
        <input type="text" class="form-control"
               name="guarantor1"
               placeholder="guarantor1" id="guarantor1"
               value="@if(isset($dataTypeContent-
                >guarantor1)){{ old('guarantor1', $dataTypeContent->guarantor1) 
                  }}@else{{old('guarantor1')}}@endif">
    </div>

    <div class="form-group">
        <label for="name">Guarantor2</label>
        <input type="text" class="form-control"
               name="guarantor2"
               placeholder="guarantor2" id="guarantor2"
               value="@if(isset($dataTypeContent-
               >guarantor2)){{ old('guarantor2', $dataTypeContent->guarantor2) 
                }}@else{{old('guarantor2')}}@endif">
    </div>


    <div class="form-group">
        <label for="name">Academic_record</label>
        <input type="text" class="form-control"
               name="academic_record"
               placeholder="academic_record"
               id="academic_record"
               value="@if(isset($dataTypeContent-
              >academic_record)){{ old('academic_record', $dataTypeContent-
            >academic_record) }}@else{{old('academic_record')}}@endif">
    </div>

    <div class="form-group">
        <label for="name">Work Experience</label>
        <input type="text" class="form-control"
               name="work_experience"
               placeholder="work_experience"
               id="work_experience"
               value="@if(isset($dataTypeContent-
                >work_experience)){{ old('work_experience', $dataTypeContent-
            >work_experience) }}@else{{old('work_experience')}}@endif">
    </div>

    <div class="form-group">
        <label for="name">Note</label>
        <input type="text" class="form-control"
               name="notes"
               placeholder="notes" id="notes"
               value="@if(isset($dataTypeContent-
                    >notes)){{ old('notes', $dataTypeContent->notes) 
              }}@else{{old('notes')}}@endif">
    </div>

    </div><!-- panel-body -->

    <div class="panel-footer">
        <button type="submit" class="btn btn-
           primary">Submit</button>
    </div>
</form>
<iframe id="form_target" name="form_target"
        style="display:none"></iframe>
<form id="my_form" action="{{ route('voyager.upload') }}"
      target="form_target" method="post"
      enctype="multipart/form-data"
      style="width:0;height:0;overflow:hidden">
    {{ csrf_field() }}
    <input name="image" id="upload_file" type="file"
           onchange="$('#my_form').submit();this.value='';">
    <input type="hidden" name="type_slug" id="type_slug"
           value="{{ $dataType->slug }}">
</form>

这是我的Profiles表的Model代码:

<?php

namespace TCG\Voyager\Models;

use Illuminate\Database\Eloquent\Model;
use TCG\Voyager\Facades\Voyager;

class Profile extends Model
{
   protected $table = 'profiles';

protected $fillable = [
    'Staff_id',
    'Title',
    'First_name',
    'Middle_name',
    'last_name',
    'Gender',
    'DOB',
    'Phone_number',
    'Company',
    'Department',
    'Unit',
    'Date_employed',
    'Date_of_exit',
    'Mode_of_exit',
    'Employment_Status',
    'Guarantor1_Details',
    'Guarantor2_Details',
    'Academic_Record',
    'Work_Experience',
    'Notes',
]; 
}

1 个答案:

答案 0 :(得分:0)

将此行添加到模型中以允许其余数据进入数据库

protected $fillable = ['name_of_column', 'name_of_thenextcolumn'];