mercredi 18 décembre 2019

The POST method is not supported for this route. Supported methods: GET, HEAD, PUT, PATCH, DELETE

The POST method is not supported for this route. Supported methods: GET, HEAD, PUT, PATCH, DELETE. I tried to do every solutions but it still same problem web.php

<?php


Route::resource('tasks','TasksController');

View tasks/create

<form action="" method="POST" class="form-horizontal">
                    @csrf
                    <!-- Task Name -->
                    <div class="form-group">
                        <label for="task-name" class="col-sm-3 control-label">Task</label>
                        <div class="col-sm-6">
                            <input type="text" name="name" id="task-name" class="form-control" value="" required>
                        </div>
                    </div>

                    <!-- Add Task Button -->
                    <div class="form-group">
                        <div class="col-sm-offset-3 col-sm-6">
                            <button type="submit" class="btn btn-default">
                                <i class="fa fa-btn fa-plus"></i>Add Task
                            </button>
                        </div>
                    </div>
                </form>

Controller TasksController

  public function index()
        {

            $tasks=Task::all();
            return view('tasks.index',compact('tasks'));
        }

        public function create()
        {
            //
            return view('tasks.create');
        }

        public function store(Request $request)
        {

            $this->validate($request,[
            'name'=>'required|max:20'
            ]);
            //Create Tasks
            $task=new Task;
            $task->name=$request->input('name');
            $task->save();
            return redirect('/tasks')->with('success','Task Created');
        }

Help me i don't know what is a problem Thank you



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire