dougu6815 2019-03-04 11:04
浏览 335

如何在Laravel中重定向并在模式中显示信息

I have list of notifications in a table and with a button beside it to view the recipients in a modal. Here's what I have done:

notification.blade.php

<div class="recipient_modal">
    <div class="apply_box">
        <div class="rec_close">
            <img src="../../assets/images/close.png" alt="close">
        </div>
        {{-- loop for recipients --}}
    </div>
</div>


<div class="recipients">
     <a class="btn pink rec_btn" href="{{ url('/recipients', 1) }}">Recipients</a>
</div>

web.php

Route::get('/recipients/{news}', 'Admin\NotificationController@recipients');

NotificationController.php

public function recipients()
{
    $messageOne = ['6','7','8'];

    $news = News::with('contest');
    $received = $news->whereIn('message_one', $messageOne)->orderBy('created_at', 'desc')->paginate(15);

    return Redirect::back()->with(['received'=>$received ]);
}

But the problem for this one, it returns Page not Found error. I'm trying to display the recipients information in a modal and I don't have idea for this one. Should I use ajax and how to do it?

  • 写回答

2条回答 默认 最新

  • drnpwmq4536 2019-03-04 11:16
    关注
    Route::get('/recipients/{news}', 'Admin\NotificationController@recipients');
    

    Because in the above line you had passed a parameter and in your controller file the method name does not have any parameter, your method should be like

    public function recipients($news)
    {
      $messageOne = ['6','7','8'];
    
      $news = News::with('contest');
      $received = $news->whereIn('message_one', $messageOne)->orderBy('created_at', 'desc')->paginate(15);
    
      return Redirect::back()->with(['received'=>$received ]);
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧