skip to Main Content

I’m currently working on FCC laravel 5.8 tutorial
However, i’m trying to build it on laravel 8.

Cant seem to find a way to make the route post work

Route::post('/p', [AppHttpControllersPostsController::class, 'store']);
<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;

class PostsController extends Controller
{
    public function create()
    {
        return view('posts.create');
    }

    public function store(){
        //dd('hit');
        dd(request()->all());
    }
}

I’ve tried using @csrf

2

Answers


  1. Chosen as BEST ANSWER

    I was able to solve this issue because of the button type="button" that I included should be type="submit" or totally blank.


  2. You can try importing the Controller at the top and then referring it inside the Route initiation.

    use AppHttpControllersPostsController;
     
    Route::post('/p', [PostsController::class, 'store']);
    

    Also, check whether the Full URL that you’re calling matches the route URI correctly.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search