Error sending information to the bank. Editing Form

0

I have an edit form for a posts feed. When I click to save the edit the following error appears:

SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "title" 
violates not-null constraint
DETAIL: Failing row contains (1, 1, null, null, null, 2018-04-24 10:04:55). 
(SQL: update "feeds" set "title" = , "description" = , "updated_at" = 2018- 
04- 24 10:04:55 where "id" = 1)

It's as if you're sending information in white, but there's nothing blank.

feed-update.blade.php

@extends('layouts.app')

@section('content')
<div class="container">
    <form action="<?php echo action('HomeController@save', $feed->id); ?>" method="POST">
       <input type="hidden" name="_token" value="<?php echo csrf_token(); ?> ">
       <h1>Editar Post</h1>
       <b>Publicado por: {{$feed->user->name}} </b><br>


       <b>Título:</b><input class="form-control" type="text" value="{{$feed->title}}">
       <br>
       <b>Descrição:</b><input class="form-control" type="text" value="{{$feed->description}}">
       <br>

       <button type="submit" class="btn btn-success">Salvar</button>    
   </form>
</div>
@endsection

HomeController @ save

    public function save($idFeed)
    {
       $title = Request()->input('description');
       $description = Request()->input('title');

       $feed = feed::find($idFeed);
       $feed->description = $description;
       $feed->title = $title;
       $feed->save();

       return redirect()->action('HomeController@index');
    }
    
asked by anonymous 24.04.2018 / 15:15

1 answer

2

Form Fields do not have the name attribute, so they are not being received in the controller. Here is a correction:

@extends('layouts.app')

@section('content')
<div class="container">
    <form action="<?php echo action('HomeController@save', $feed->id); ?>" method="POST">
       <input type="hidden" name="_token" value="<?php echo csrf_token(); ?> ">
       <h1>Editar Post</h1>
       <b>Publicado por: {{$feed->user->name}} </b><br>


       <b>Título:</b><input class="form-control" type="text" value="{{$feed->title}}" name="title">
       <br>
       <b>Descrição:</b><input class="form-control" type="text" value="{{$feed->description}}" name="description">
       <br>

       <button type="submit" class="btn btn-success">Salvar</button>    
   </form>
</div>
@endsection
    
24.04.2018 / 15:23