我正在使用Laravel 5.2。当我转到我的路线时,我遇到了2个错误:
错误1:
Handler.php第103行中的NotFoundHttpException:
模型[App \ Group]没有查询结果。
错误2:
Builder.php第209行中的ModelNotFoundException:
模型[App \ Group]没有查询结果。
我的路线:
Route::get('/groups/create/', [
'uses'=>'GroupController@creategroup',
'as'=>'creategroup'
]);
Route::post('/groups/create/', [
'uses'=>'GroupController@newgroup',
'as'=>'newgroup'
]);
我的控制员:
public function creategroup(){
return view('creategroup');
}
public function newgroup(Request $request){
$this->validate($request, [
'groupname'=>'required|min:5',
]);
$group=new Group();
$group->name=$request['groupname'];
$group->user_id=Auth::user()->id;
$group->save();
$users = DB::table('groups')
->join('group_user', 'groups.id', '=', 'group_user.group_id')
->where('group_user.user_id',Auth::user()->id)
->select('groups.*')
;
$groups = DB::table('groups')
->where('user_id',Auth::user()->id)
->select('*')
->unionAll($users)
->get();
return view('mygroups',['groups'=>$groups]);
}