URL을 통해 레코드 ID를 전달하는 것이 일반적으로 좋은 생각이 아니라는 것을 알고 있지만 제 경우에는 어떻게 피할 수 있는지 궁금합니다.
내 목표는 사용자 대시 보드에 작업 상태를 나열하고 사용자가 상태를 조정할 수 있도록하는 것입니다.
내 뷰를 만들고 세션을 사용하여 변수를 전달합니다.
userController.php
public function getdashboard()
{
//reading the user information
$arrPageData['user'] = Sentry::getUser();
//reading the job interviews
$arrPageData['jobInterviews'] = JobInterview::readCurrentInterviews($this->userID);
return View::make('clients.dashboard', $arrPageData);
}
이 부분은 훌륭하게 작동하며 경로에서 레코드 ID를 사용하지 않습니다. 대시 보드보기에서 jobInterviews를 반복합니다. DB 테이블에 나열된 상태에 따라 사용자 옵션을 제공합니다.
파일보기 : dashboard.blade.php (스 니펫)
@foreach ($jobInterviews as $interviews)
@if ($interviews->j == $job->id)
<tbody>
<tr>
<td>
{{$interviews->contact_name}}
@if ($interviews->status == 'interview request accepted')
<a href="#" class="btn btn-danger btn-small" data-toggle="modal" data-target=".mymodal{{ $interviews->interview_id }}">Hire</a>
@elseif ($interviews->status == 'hired')
<button id="complete" class="btn btn-info btn-small">Mark Project Complete</button>
@endif
</td>
<td>{{$interviews->status}} </td>
</tr>
</tbody>
...
내가 가진 문제는 작업 상태 변경을 완료하기 위해 메서드를 호출하고 레코드 ID를 전달한다는 것입니다.
아직 dashboard.blade.php에 있습니다.
<form action="../jobs/offer/{{$interviews->interview_id}}" method="post">
그런 다음 다음을 통해 라우팅됩니다.
Route::post('/jobs/offer/{id}','JobController@jobOffer');
모든 것이 내가 원하는대로 작동하지만 보안 관점에서 제대로하고 있다고 생각하지 않습니다. 반복 한 배열에서 데이터를 가져올 때 경로에서 레코드 ID를 사용하는 것 외에도 jobOffer 메서드를 호출하고 상태를 변경하는 더 좋은 방법이 있습니까?
도움을 주셔서 미리 감사드립니다.
시도해 볼 수 있습니다.
{{ Form::open(array('action' => array('JobController@jobOffer', $interviews->interview_id))) }}
<!-- Rest of the form fields -->
{{ Form::close() }}
당신이 이런 식으로하지 추가 할 필요가 csrf/_method
수동으로 입력을 기본적으로 그건 METHOD
것 POST
당신이를 생략 할 수 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다