양식을 제출할 때 경로와 함께 ID를 전달하려고합니다. 나는 그것이 작동라우트 라우트를 통한 매개 변수 전달
<form class="form-horizontal" role="form" method="POST" action="{{ route('submit.lmo_list', ['id'=>7]) }}">
같은 하드 코드 된 ID를 통과 할 때. i는 사용자 테이블
<form class="form-horizontal" role="form" method="POST" action="{{ route('submit.lmo_list', ['id'=>auth()->user->id]) }}">
이것도 작동 데이터베이스 ID 필드는 사용자의 ID를 나타낸다로부터 ID를 통과 할 때 표 7
와 외래 키 ID를 나타낸다.
나는 알림 테이블에서 ID를 전달하려는 내가
<form class="form-horizontal" role="form" method="POST" action="{{ route('submit.lmo_list', ['id'=>notification()->id]) }}">
처럼 뭔가를하려고 할 때이 방법 알림 찾을 수 없습니다라는 오류가 발생합니다.
양식을 제출하고 올바르게 URL의 ID를 표시 한 후 내가 URL로 알림 ID를 전달하고 여기
public function create(Request $request)
{
$notification = Notification::create([
'unit_code'=>$request->unit_code,
'unit_name'=>$request->unit_name,
'project_title'=>$request->project_title,
'project_ref_number'=>$request->project_ref_number,
'storage_location'=>$request->storage_location,
'keeper_name'=>$request->keeper_name,
'user_id'=>Auth::user()->id
]);
return redirect()-> route('show.lmo_form', $notification->id);
}
통지 컨트롤러.
통지 LMO 제어기
public function create(Request $request, $notification_id)
{
/*this loop is because im adding rows dynamically to the table*/
$count = count($request->input('lmo_name'));
for ($i=0; $i<$count; $i++){
$data = AddLmoNotification::create([
'lmo_name'=>$request->lmo_name[$i],
'lmo_risk_level'=>$request->lmo_risk_level[$i],
'lmo_quantity'=>$request->lmo_quantity[$i],
'lmo_volume'=>$request->lmo_volume[$i],
'notification_id'=>$notification_id
]);
}
return redirect()->route('show.go_to_notification');
}
이 첫번째 테이블의 ID와 함께 두 번째 테이블에 데이터를 삽입하는 컨트롤러이다. 내가 양식을 제출하면
내가 오류를
정의되지 않은 메서드 통지()
는 등 같은 다른 파일을보기 위해 필요한 경우 알려줘 제발 도와주세요를 얻을 수 모델 및 데이터베이스 마이그레이션을 지원합니다.
은' 는 정의되지 않은 변수 말한다 표. 통지 테이블 hasMany notification_type_a. 그래서 notification_type_a 테이블에 알림 키를 외래 키로 전달하려고합니다. – Mill3r
초기 '정의되지 않은 메서드 알림()'은 뷰에서 메서드가 없다는 것이기 때문입니다. 통지에 통보 했습니까? –
내가 그랬는지 나는 정말로 모른다. 방금 laravel을 시작했는데, 바보 인 것에 대해 유감스럽게 생각합니다. 너는 정교하게 말해 줄 수 있니? 감사합니다 – Mill3r