我想保存一些表单数据,但出现错误。
错误
Action App\Http\Controllers\Admin\ConcursoController@store not defined. (0)
我的表格
{!! Form::open(['action'=>'Admin\ConcursoController@store', 'method' => 'POST']) !!}
<div class="form-group">
{{Form::label('company','Entidade')}}
{{Form::text('company','',['class' => 'form-control', 'placeholder' => 'Nome da entidade aquí..'])}}
</div>
{{Form::submit('submeter', ['class'=>'btn btn-primary'])}}
{!! Form::close() !!}
我的路线
$this->group(['middleware' => ['auth:admin'], 'namespace' => 'Admin', 'prefix' => 'admin'], function(){
$this->get('/', 'AdminController@index')->name('admin.home');
$this->resource('concursos', 'ConcursoController');
});
控制器索引方法
public function index()
{
$concursos = Concurso::all();
$title = 'Concursos';
return view('admin.concursos.index',compact('title'))->with('concursos',$concursos);
}
控制器创建方法
public function create()
{
return view('admin.concursos.create');
}
控制器存储方法
public function store(Request $request)
{
$this->validate($request, [
'title' => 'required',
'body' => 'required',
]);
//Criar concurso
$concurso = new Concurso;
$concurso->title = $request->input('title');
$concurso->body = $request->input('body');
$concurso->save();
return redirect('/admin/concursos')->with('Success', 'Concurso Adicionado');
}
Laravel 5.7.14版
答案 0 :(得分:0)
可能检查以下文件:App\Http\Controllers\Admin\ConcursoController
,看看是否有一个名为“ store”的函数/方法。错误很简单,脚本无法找到该函数。
答案 1 :(得分:0)
替换表格 ['route'=> ['concursos.store']
喜欢
{!! Form::model($transactions, ['route' => ['transaction.store'], 'method' => 'POST','class'=>"form-horizontal"]) !!}