我有错误 NotFoundHttpException模型[App \ ThreadForum]没有查询结果
我的 web.php :
Route::get('/threads','ThreadForumController@index');
Route::post('/threads','ThreadForumController@store');
Route::get('/threads/create','ThreadForumController@create');
Route::get('/threads/{thread}','ThreadForumController@show')->name('threads.show');
我的模型:
namespace App;
use Illuminate\Database\Eloquent\Model;
class ThreadForum extends Model
{
protected $fillable = [
'user_id','title','body'
];
public function path(){
return route('threads.show',$this->id);
}
public function replies(){
return $this->hasMany('App\Reply');
}
public function creator(){
return $this->belongsTo('App\User', 'user_id');
}
public function addReply($reply){
$this->replies()->create($reply);
}
}
我的控制器:
namespace App\Http\Controllers;
use App\ThreadForum;
use Illuminate\Http\Request;
class ThreadForumController extends Controller
{
public function __construct()
{
$this->middleware('auth')->only('store');
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$threads = ThreadForum::all();
return view('threads.index', compact('threads'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('threads.create');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
dd('store');
/*$thread = ThreadForum::create([
'user_id'=>auth()->id(),
'title'=>$request['title'],
'body'=>$request['body']
]);
redirect($thread->path());*/
}
/**
* Display the specified resource.
*
* @param \App\ThreadForum $threadForum
* @return \Illuminate\Http\Response
*/
public function show(ThreadForum $thread)
{
return view('threads.show',compact('thread'));
}
/**
* Show the form for editing the specified resource.
*
* @param \App\ThreadForum $threadForum
* @return \Illuminate\Http\Response
*/
public function edit(ThreadForum $threadForum)
{
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\ThreadForum $threadForum
* @return \Illuminate\Http\Response
*/
public function update(Request $request, ThreadForum $threadForum)
{
}
/**
* Remove the specified resource from storage.
*
* @param \App\ThreadForum $threadForum
* @return \Illuminate\Http\Response
*/
public function destroy(ThreadForum $threadForum)
{
//
}
}
所有功能都运行良好,但是当我为商店新记录运行post(' / threads')时,我收到错误。 我尝试使用dd(' store')进行调试,但我没看到这个文本,只是错误。 我该如何解决? 感谢。
答案 0 :(得分:0)
我无法发表评论,但要转储你必须使用CustomDBParameterGroup:
Type: AWS::RDS::DBParameterGroup
Properties:
Description: !Join [' ', ['Custom Option Group for application - ', !Ref AppName, !Ref EnvironmentType]]
Family: sqlserver-ee-13.0
Parameters:
remote access: 0
而不是dd($request)