rebduvid
rebduvid

Reputation: 1144

Laravel 5.2 Redirect shows blank page

The redirect() method show a blank page. Doesn't work and doesn't show an 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 which 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 fails.

$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.

Upvotes: 0

Views: 59

Answers (1)

Hamelraj
Hamelraj

Reputation: 4826

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');
}

Upvotes: 0

Related Questions