dimanche 8 décembre 2019

Laravel save not is not working working, database not getting updated

On my homepage, I have created a comment form that I am submitting to a table named comments. However, the database is not getting updated once I submit the form. this is my store function

public function store(Request $request){
    $validatedData = $request->validate([
        'name' => 'required',
        'email' => 'required',
        'phone_number' => 'required',
        'ask' => 'required'
    ]);
     $comments = new Comment;
     $comments->name = $request->input('name');
     $comments->email = $request->input('email');
     $comments->phone_number = $request->input('phone_number');
     $comments->ask = $request->input('ask');
     $comments->save();
     return redirect('/welcome');
}

this is my comment model

    Class Comment extends Model
{
    protected $fillable =[
        'name', 'email', 'phone_number', 'ask'
    ];
    protected $primaryKey = 'id';
}

this is my migration

Schema::create('comments', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->timestamps();
        $table->string('name');
        $table->string('email');
        $table->integer('phone_number');
        $table->string('ask');
    });


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire