dongshuzhuo5659 2016-07-23 20:57
浏览 55

Laravel 5.2重定向没有工作

The redirect() method show a blank page. Doesn't work and doesn't show error, also there is no available information in the error log (not in storage neither in the apache log)

The view is load ok, and in first place need to check wich form should show. if is to modify or to create a new item. The problem is in the modify form, when try to recover DB info, if the item not found should redirect to the list. And in this redirection the system fail.

$tituloSeccion = 'Modificar Banner';
$accionForm = 'BannerController@modificar';
$banners = App\Banner::where('id', '=', $variable_id)->get();
if(count($banners) > 0)
{
    $banner = $banners[0];
    $titulo = $banner->titulo;
    $descripcion = $banner->descripcion;
    $link = $banner->link;
    $imagen = $banner->imagen;
    $hasta = $banner->hasta;
}
else
{
    return redirect('/dspanel/3/2');
}

So in a case of $banners = 0 If I put "echo" before and after the redirect the one before the redirect is showed and the next after the redirect is not showed. Without "echo" only I receive Blank Screen. No redirection.

Best Regards,

  • 写回答

1条回答 默认 最新

  • douyinglan2599 2016-07-24 02:45
    关注

    don't use else condition and if you show your controller function which you need to redirect easy to help you . but try this way

    public function count(){
    if(count($banners) > 0){
            $banner = $banners[0];
      }
        return redirect('/dspanel/3/2');
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题