I have a PostsController that's supposed to show page for Image Upload, but it gets loaded under http://127.0.0.1:8000/p enpoint, instead of http://127.0.0.1:8000/p/create endpoint.
PostsController:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use function Symfony\Component\String\b;
class PostsController extends Controller
{
public function create() {
return view('posts.create');
}
public function store()
{
dd(request()->all());
}
}
Routes:
<?php
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Auth;
Auth::routes();
Route::get('/p/create', [App\Http\Controllers\PostsController::class, 'create']);
Route::post('/p', [App\Http\Controllers\PostsController::class, 'store']);
Route::get('/profile/{user}', [App\Http\Controllers\ProfilesController::class, 'index'])->name('profile.show');
create.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<form action="/p" enctype="multipart/form-data" method="post">
@csrf
<div class="row">
<div class="col-8 offset-2">
<div class="row">
<h1>Add New Post</h1>
</div>
<div class="form-group row">
<label for="caption" class="col-md-4 col-form-label">{{ __('Post Caption') }}</label>
<input id="caption"
type="text"
class="form-control @error('caption') is-invalid @enderror"
name="caption"
value="{{ old('caption') }}">
@error('caption')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
<div class="row">
<label for="image" class="col-md-4 col-form-label">{{ __('Post Image') }}</label>
<input type="file" class="form-control-file" id="image" name="image">
@error('image')
<strong>{{ $message }}</strong>
@enderror
<div class="row pt-4">
<button class="btn btn-primary">Add New Post</button>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
@endsection
And my file structure:
I'm really not sure how this happened, it worked then I proceeded to work on this project and then it stopped working at some point. I've played around with different names etc.. always the same problem.