0
View :: make ('view')를 반환 한 후 일부 코드를 실행하고 싶습니다. laravel에서도 가능합니까?laravel return 후 코드 실행
if (!$conversation == null) {
\t \t \t // here I update last_viewed time
\t \t $conversation_memb=$conversation->members()->where('user_id',Auth::user()->id)->first();
\t \t $conversation_memb->last_viewed = time();
\t \t $conversation_memb->save();
\t \t
// here I return View with some data
\t \t \t return View::make('messages.conversation')->with('conversation',$conversation)->with('messages',$conversation->messages()->orderBy('created_at','DESC')->take(10)->get()->reverse());
\t \t \t
\t \t }
그래서 난 단지 내가로드 한 후 last_view의 시간을 업데이트 할 : 나는 내보기 그러나 나쁜 관행의 종류 속으로 내 코드를 넣을 수 있습니다 알고, 여기에 내 코드입니다 보기, 그래서 메시지는 "읽지 않은"같이 표시됩니다
함수에서 돌아 오면 해당 함수가 완료됩니다. 컨트롤러 나 뷰에있는 모든 PHP 코드는 응답이 클라이언트에 전송되기 전에 실행됩니다. 브라우저에서 완료해야하는 경우 Javascript를 사용해야합니다. 당신은 아마 시간을 업데이 트하는 아약스 요청을 사용할 수 있습니다. –