2017-06-02 5 views
1

ich ein Login-System mit Laravel erstellen und Sentinel habe ich ein neues Feld ‚Standort‘ in Benutzer-Tabelle wie diese Allgemeiner Fehler: 1364 Feld ‚Standort‘ nicht über einen Standardwert

genannt
Schema::create('users', function (Blueprint $table) { 
    $table->increments('id'); 
    $table->string('email'); 
    $table->string('password'); 
    $table->text('permissions')->nullable(); 
    $table->timestamp('last_login')->nullable(); 
    $table->string('first_name')->nullable(); 
    $table->string('last_name')->nullable(); 
    $table->string('location'); //this is my field 
    $table->timestamps(); 
    $table->engine = 'InnoDB'; 
    $table->unique('email'); 
}); 

nach dass ich Code ausführen zu migrieren: Refresh und i hinzugefügt $ ausfüllbare Liste das neue Feld, wie die

protected $fillable = [ 
    'email', 
    'password', 
    'last_name', 
    'first_name', 
    'permissions', 
    'location' 
]; 

und dies ist mein Code in Controller auch

namespace App\Http\Controllers; 

use Illuminate\Http\Request; 
use Sentinel; 

class RegistrationController extends Controller 
{ 
    public function register() 
    { 
     return view('authentication.register'); 
    } 

    public function postRegister(Request $request) 
    { 
     $user = Sentinel::registerAndActivate($request->all()); 
     dd($user); 
    } 
} 

wenn ich neue Benutzerdaten in eingefügt i

QueryException in Connection.php line 770: SQLSTATE[HY000]: General error: 1364 Field 'location' doesn't have a default value (SQL: insert into Benutzer diesen Fehler hatte ( E-Mail , first_name , last_name , Passwort , updated_at , created_at ) values ([email protected], ahmed, masry, $2y$10$jAIN6mEXvayLXmY8JmnUHOAu36l3owetg3TuOHnpUtjs1uR89dEYm, 2017-06-02 00:49:53, 2017-06-02 00:49:53))

Ich habe versucht, dieses Problem durch die Änderung falsch streng zu lösen, aber die Fehlermeldung funktioniert immer noch und die Zeile eingefügt ohne den Standort Feld Wert Ich sah das Ort Feld in füllbaren Array, aber ich habe es nicht in Attribute Array kann mir jemand helfen?

hier ist es meine Form

<form action="/register" method="POST"> 
    {{ csrf_field() }} 

    <div class="form-group"> 
    <div class="input-group"> 
     <span class="input-group-addon"><i class="fa fa-envelope"></i></span> 

     <input type="email" name="email" class="form-control" placeholder="[email protected]"> 
    </div>       
    </div> 


    <div class="form-group"> 
    <div class="input-group"> 
     <span class="input-group-addon"><i class="fa fa-user"></i></span> 

     <input type="text" name="first_name" class="form-control" placeholder="First Name"> 
    </div>       
    </div> 


    <div class="form-group"> 
    <div class="input-group"> 
     <span class="input-group-addon"><i class="fa fa-user"></i></span> 

     <input type="text" name="last_name" class="form-control" placeholder="Last Name"> 
    </div>       
    </div> 


    <div class="form-group"> 
    <div class="input-group"> 
     <span class="input-group-addon"><i class="fa fa-map-marker"></i></span> 

     <input type="text" name="lacation" class="form-control" placeholder="Location"> 
    </div>       
    </div> 


    <div class="form-group"> 
    <div class="input-group"> 
     <span class="input-group-addon"><i class="fa fa-lock"></i></span> 

     <input type="password" name="password" class="form-control" placeholder="Password"> 
    </div>       
    </div> 

    <div class="form-group"> 
    <div class="input-group"> 
     <span class="input-group-addon"><i class="fa fa-lock"></i></span> 

     <input type="password" name="password_confirmation" class="form-control" placeholder="Password Confirmation"> 
    </div>       
    </div> 

    <div class="form-group"> 

     <input type="submit" value="Register" class="btn btn-success pull-right"> 

    </div>      
</form> 
+0

posten Sie Ihr Formular auch, bitte –

+0

ja ich habe migrieren: aktualisieren Sie nach dem Hinzufügen des neuen Feldes zu $ ​​befüllbar –

Antwort

1

In Ihrem Formular Sie

<input type="text" name="lacation" class="form-control" placeholder="Location"> 

Beachten Sie die falsche Schreibweise von name="lacation"

sollte es sein name="location"

<input type="text" name="location" class="form-control" placeholder="Location"> 
+0

vielen Dank sehr –

+0

@AhmedMasry Wenn das funktioniert, bitte akzeptieren Sie es als die Antwort –

+0

Ich habe das gleiche Problem. Ich überprüfte alle meine Schreibweisen. Versucht alle möglichen Dinge, aber immer noch denselben Fehler. Würden Sie mir bitte helfen? –

Verwandte Themen