i know it’s a silly issue but I am at the very beginning stage of learning Laravel without any guidance or help from anyone. so please, don’t mind. I’ll delete it after getting the answer.
I am using Laravel with react inertia. i am submitting a form from ‘/p/create’ to ‘/p’ route that is returning me 404 not found error. can’t find what went wrong here.
My routes:
Route::get('/p/create', function () {
return Inertia::render('Posts');
})->name('posts.create');
Route::post('/p', [PostController::class, 'store']);
my PostController:
<?php
namespace AppHttpControllers;
use AppHttpControllersController;
use IlluminateHttpRequest;
class PostController extends Controller
{
public function store()
{
dd(request()->all())
}
}
The form of ‘/p/create’
export default function Posts({ auth }) {
return (
<div className="post">
<Navbar auth={auth} />
<form
encType="multipart/form-data"
action="{{ route('posts') }}"
method="POST"
>
<input
type="hidden"
name="_token"
value="{!! csrf_token() !!}"
/>
<input type="file" name="image" />
<textarea name="caption" />
<button type="submit">Post</button>
</form>
</div>
);
}