lundi 18 avril 2016

Laravel Trying to get property of non-object Error

I have an error that I can not understand why this happened. I try to return a view but laravel looks for a different view that I didn't define. Another error is laravel looks for a variable I defined but undefined variable occurs. I think this happens because of laravel looks for undefined view.

This is my route. php code about that:

Route::get('/{kategori}', 'front\HaberController@kategori' ); 
        Route::get('/{kategori}/{haber}/{id}', 'front\HaberController@haber' );

And this is my function in the HaberController

public function haber( $kategoriSlug = "Genel", $haberSlug , $id = 0 )
{


GoruntulenmeSayaci::sayaciArtir( $this->haberVeriTuruId, $id ) ;


    if( Cache::has( 'haberDetay'.$id ) ){

        return Cache::get( 'haberDetay'.$id );

    }else{





            if( $id != 0 && is_numeric( $id ) ){
                if( isset ( session('yetki')->haber ) && session('yetki')->haber  > 1 ){  
                    $haber = DB::table('haberler')->where( "id", $id )->first(); 
                }else{
                    $haber = DB::table('haberler')->where( "id", $id )->where( "aktif_pasif", 1 )->first(); 
                }

            }else{
                return false;       
            }

            $anasayfaUstKutu = self::getAnasayfaUstKutu();

            $anasayfaSlider = self::getAnasayfaSlider();

            $kategori = DB::table('kategoriler')->where( "slug", $kategoriSlug )->where( "veri_turu_id", $this->haberVeriTuruId )->first(); 


            $anasayfaGrid = self::getAnasayfaGrid();



            $anasayfaVideolar = self::getAnasayfaVideolar();
            $anasayfaGaleriler = self::getAnasayfaGaleriler();
            $reklamlar = self::getReklamlar();




            $sonuc = view("front.haber.detay", [  
                                                "anasayfaUstKutu" => $anasayfaUstKutu, 
                                                "anasayfaSlider" => $anasayfaSlider, 
                                                "anasayfaVideolar" => $anasayfaVideolar,
                                                "anasayfaGaleriler" => $anasayfaGaleriler,
                                                "anasayfaGrid" => $anasayfaGrid,
                                                "haber" => $haber,
                                                "kategori" => $kategori,
                                                "reklamlar" => $reklamlar


                                             ]);



    Cache::put( 'haberDetay'.$id , $sonuc->render(), $this->cacheSuresi );

            return $sonuc;

    }




}

When I try these codes laravel gives this error:

Undefined variable: reklamlar (View: /home/yazilim/resources/views/front/haber/kategori.blade.php)

Thanks for help.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire