Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

knn's avatar
Level 1

Eloquent save() method not saving into DB, no error message, Tinker save() works.

Hello

I am developing on a local machine and deploying to a hosting website. The application and saving into DB works fine on my local machine. However, when I push to the testing server, saving from POST-method form does not work.

I tried with Tinker in Terminal through SSH and saving into DB and creating a Model works on the hosting server, so it is not because of the DB-connection (MySQL).

The form im posting from:

    <form method="post" action="/admin/seiten/">
    {{ csrf_field() }}

    <!-- insert titel of the text -->
                <div class="col-lg-10 col-md-10 col-sm-9 col-xs-12">
                    <input type="text" class="form-control" id="usr" name="title" required>
                </div>

        <!-- insert text -->

                <div class="col-lg-10 col-md-10 col-sm-9 col-xs-12">
                    <textarea class="form-control" rows="5" id="comment" name="content" required></textarea>
                </div>

    </form>

Route (with prefix admin):

Route::post('/seiten', 'AdminSeitenController@store');

Controller:

    public function store(Request $request)
    {
        $seite = new Seite;

        $seite->titel = $request->input('title');
        $seite->inhalt = $request->input('content');

        $seite->save();

        return Redirect::route('admin.seiten');
    }

Has anybody also had same issues and probably a fix for it?

Thanks.

EDIT: dd($seite) also not working...

0 likes
3 replies
tykus's avatar

Are you actually hitting the store method in that controller? What is your testing server?

1 like
Snapey's avatar
Snapey
Best Answer
Level 122

You have absolute URL in your form

action="/admin/seiten/"

This will only work if your test server has Laravel public folder at the document root. If you are loading the form with a url like /public/admin/sieten then your post will fail

Either way, you should open the network tools in your browser and check what is posted to the server and what the response is

1 like
knn's avatar
Level 1

Thank you very much guys for the hints.

I replaced the action part in HTML with action="{{ action('AdminSeitenController@store') }}"

<form method="post" action="{{ action('AdminSeitenController@store') }}">

And it solved my problem. So both replies were more or less correct: It didn't post because route was not hit.

Please or to participate in this conversation.