如何在Laravel中使用get route插入数据发布

我如何在Laravel中使用GET路由发送POST方法?

我的路线代码

Route::get('domain_detail/{domain_name}','domain_detailController@index');

我在domain_detail文件夹中的查看代码

<form method="post" action="{{url('domain_detail')}}/{{strtolower($domain_detail->domain_name)}}">
    <div class="form-group">
        <label for="namefamily">namefamily</label>
        <input type="text" class="form-control round shadow-sm bg-white text-dark" name="namefamily">
    </div>
    <div class="form-group">
        <label for="mobile">mobile</label>
        <input type="text" class="form-control round shadow-sm bg-white text-dark" name="mobile">
    </div>
    <div class="form-group">
        <label for="myprice">myprice</label>
        <input type="number" class="form-control round shadow-sm bg-white text-dark" name="myprice">
    </div>
    <div class="form-group">
        <input type="submit" name="send_price" class="btn btn-success" value="submit">
    </div>
</form>

我的控制器

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;


class domain_detailController extends Controller
{
    public function index($domain_name)
    {
        $domain_detail_exist = DB::table("domains")->where('domain_name', $domain_name)->exists();
        if ($domain_detail_exist) {
            $domain_detail = DB::table("domains")->where('domain_name', $domain_name)->first();

            return view('domain_detail/index', ['domain_detail' => $domain_detail]);
        } else {
            return view('404');
        }
    }

    public function create()
    {
        return view('domain_detail.index');
    }
}

在控制器中,我没有在创建函数中放置代码,但是当单击表单中的提交按钮时,出现此错误

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException   该路由不支持POST方法。支持的方法:   GET,HEAD。
评论