Home > Mobile >  Laravel 5.8 to Laravel 8 Route::post('/p', [App\Http\Controllers\PostsController::class
Laravel 5.8 to Laravel 8 Route::post('/p', [App\Http\Controllers\PostsController::class

Time:10-31

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', [App\Http\Controllers\PostsController::class, 'store']);
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

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

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

I've tried using @csrf

CodePudding user response:

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

use App\Http\Controllers\PostsController;
 
Route::post('/p', [PostsController::class, 'store']);

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

CodePudding user response:

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

  • Related