'"The GET method is not supported for this route. Supported methods: POST ."
I'm trying to add a new Post but whenever i submit i get the above error message.
This is Route:
Route::get('/p/create' , [App\Http\Controllers\PostsController::class, 'create']);
Route::post('/p' , [App\Http\Controllers\PostsController::class, 'store']);
and this is my controller:
{
    public function create(){
        return  view('posts.create');
    }
    public function store(){
        $data = request()->validate([
            'caption'=>'required',
            'image'=>'required|image',
        ]);
        $imagePath =request('image')->store('uploads' ,'public');
      //  auth()->user()->posts()->create($data);
        auth()->users()->posts()->create([
            'caption' => $data['caption'],
            'image' => $imagePath,
        ]);
        //dd(request()->all() );
        return redirect('/profile/' . auth()->user()->id);
    }
}
Anyone faced the same problem?
Solution 1:[1]
Your problem is in your client side .
You should submit your form with post method not get. for example this form send post method :
<form action="{{route('example_route')}}" method='post' >
//some html here
</form>
    					Solution 2:[2]
Try Modifying the store method to
public function store(Request $request){
        $data = $request->validate([
            'caption'=>'required',
            'image'=>'required|image',
        ]);
//...
    					Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | saeed mzr | 
| Solution 2 | Akash Manna | 
