Support the ongoing development of Laravel.io →
Database

When you try to save data to the database, the page just loads endlessly. I also tried other methods of saving, but it didn't help.зрзl

`class ContactController extends Controller{

public function submit(ContactRequest $req){

    // $contactM = new Contact();
    // $contact = $req->only(['name', 'email', 'subject', 'message']);
    // $contactM->saved($contact);
    
    $contact = new Contact();
    $contact->name = $req->input('name');
    $contact->email = $req->input('email');
    $contact->subject = $req->input('subject');
    $contact->message = $req->input('message');
    $contact->save();


    // Contact::create([
    //     'name' => $req->get('name'),
    //     'email' => $req->get('email'),
    //     'subject' => $req->get('subject'), // еще один способ добавления данных в таблицу
    //     'message' => $req->get('message'),
    // ]);

    return redirect()->route('home');
}

}`

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.