ROUTE
Route::post('/review','RentalController@review');
CONTROLLER
public function review(Request $request)
{
$review = new Reviews();
$rpId = rand();
$review->rvid=$rpId;
$review->usid_fk = Auth::user()->uid;
// $propId= $request->input('propId');
$review->prId_fk = $request->input('propId');;
$review->comment = $request->input('comment');
$review->rating = $request->input('rating');
$review->date = Carbon::now();
$review->save();
}
MIGRATE
public function up()
{
Schema::create('review', function (Blueprint $table) {
$table->integer('rvId')->primary();
$table->integer('usId_fk');
$table->foreign('usId_fk')->references('uid')->on('users');
$table->integer('prId_fk');
$table->foreign('prId_fk')->references('pId')->on('properties');
$table->date('date');
$table->integer('rating');
$table->string('comment');
});
}
VIEW
<form action="" method="POST">
<div class="modal-body">
<input type="hidden" name="propid" value=""/>
<input id="rating" name="rating" class="rating rating-loading" data-show-clear="false" data-min="0"
data-max="5" data-step="1" value="0">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">Comment</span>
</div>
<textarea name="comment" class="form-control" aria-label="Comment"></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
and the error is integrity contraintthe prId_fk cannot be null been trying to fix this a coule of days alreadyYour reply would be highly appreciatedthank you the prId_fk cannot be null integrity constraint violation
i've been trying to rerwite my code over and over again still it didnt work
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire