/**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $uri = $request->path();
     $uriExpanded = explode('/', $uri);
     $id = $uriExpanded[3];
     $userId = Auth::user()->id;
     $answer = Answers::findBySlugOrFail($id);
     if ($userId != $answer->user_id) {
         flash('You Are Not The Owner Of the Answer')->important();
         return redirect($uriExpanded[0] . '/' . $uriExpanded[1]);
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $uri = $request->path();
     $UriExpanded = explode('/', $uri);
     $q_id = $UriExpanded[1];
     $question = Questions::findBySlugOrFail($q_id);
     $a_id = $UriExpanded[3];
     $answer = Answers::findBySlugOrFail($a_id);
     $id = $answer->questions_id;
     if ($id != $question->id) {
         return redirect(action('QuestionsController@index'));
     }
     return $next($request);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(QuestionAnswerRequest $request, $qid, $aid)
 {
     $answer = Answers::findBySlugOrFail($aid);
     $answer->update($request->all());
     flash('Your Answer Has been Edited');
     return redirect(action('QuestionsAnswersController@show', [$qid, $answer->slug]));
 }