gpt4 book ai didi

php - Action App\Http\Controllers\Controller@action 未定义

转载 作者:行者123 更新时间:2023-12-03 18:38:09 24 4
gpt4 key购买 nike

我想提交一个表单,但即使定义了 Action App\Http\Controllers\About@show not defined 函数,我也总是得到 show:

<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;


class AboutController extends Controller
{
public function create()
{
return view('about.contact');
}

public function show()
{
return view('about.contactshow');
}

}

这是我的 Blade 模板 about\contact.blade.php :
{!! Form::open(array('action' => 'About@show', 'method' => 'post')) !!}

{!! Form::label('username','Username',array('id'=>'user','class'=>'')) !!}
{!! Form::text('username','user 1',array('id'=>'user','class'=>'', 'placeholder' => 'user 1')) !!}

{!! Form::submit('Click Me!') !!}


{!! Form::close() !!}

我究竟做错了什么?

最佳答案

我能够解决它。
首先,我必须将 'action' => 'About@show' 更改为 'action' => 'AboutController@show'
然后我必须在 routes.php 中注册所有 Controller 操作:

Route::post('contact_show', [
'uses' => 'AboutController@show'
]);

Route::get('contact_create', [
'uses' => 'AboutController@create'
]);

关于php - Action App\Http\Controllers\Controller@action 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42181693/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com