laravel试图获得非对象的财产

时间:2015-07-05 22:26:09

标签: php html laravel laravel-4

我在laravel 4.2中遇到错误 "试图获得非对象的财产"

以前工作得很好,所以我不知道为什么它现在不工作。

这是我的代码:

控制器:

public function id($lang,$id,$vers) {

    // $Agent = new Agent();

    // if ($Agent->isMobile()) {

    //     $data['settings'] = Courses::settings($id, $vers);
    //     $this->layout->content = View::make('gui.mobile')->with('data', $data);

    // } else {

        $data['index'] = Courses::productsIndex($id);
        $data['langs'] = Courses::langsclient($id);
        $data['settings'] = Courses::settings($id, $vers);

        $this->layout->content = View::make('gui.home')->with('data', $data);
    // }

}

模型:

public static function productsIndex($id,$html='') {

    $clients = DB::table('clients')->where('client_id',$id)->first();
    $clients_settings = DB::table('clients_settings')->where('clients_id',$id)->first();
    $courss = explode(',', $clients->products);

    $IndexCats = '';
    $IndexCats .= '<a href="#all" title="">' . trans('home.All Products') .'</a>';

    foreach($courss as $index) {

        $IndexCats .= '<a href="#' . $index . '" title="" rel="' . $index . '">' . trans('home.' .  $index) . '</a>';

    }


    $clients = DB::table('clients')->where('client_id',$id)->first();
    $cours = explode(',', $clients->coruses);
    $tabs ='';
    $links='';

    foreach($cours as $row) {

        $idcours = DB::table('courses')->where('id',$row)->get();
        $coursCount = DB::table('lessons')->where('courses_id',$row)->count();
        $clients_settings = DB::table('clients_settings')->where('clients_id',$id)->first();
        $clients_images_ebook = DB::table('mediameneger')->where('name','ebook')->where('type','image')->where('client_id',$id)->first();

        if($row == 'ebook') {

            $image_ebook = !empty($clients_images_ebook->fullpath) ? $clients_images_ebook->fullpath : url() .'/files/images/ebook.jpg';

            $tabs .= '<li class="videos ebook" style="background-image: url(' . $image_ebook . '?86400' .');">';
            $tabs .= '<p><a href="'. url() .'/gui/' . Request::segment(2) . '/'. $id .'/' . Request::segment(4) . '/ebooks">Ebook';
            $tabs .= '<span class="more"><br />';
            $tabs .= '<i class="hidden-xs cercale glyphicon glyphicon-book fa-3x"></i></span>';
            $tabs .= '</a></p>';
            $tabs .= '</li>';

        }

        if($row == 'ebook_forex') {

            $image_ebook = !empty($clients_images_ebook->fullpath) ? $clients_images_ebook->fullpath : url() .'/files/images/ebook.jpg';

            $tabs .= '<li class="videos ebook" style="background-image: url(' . $image_ebook . '?86400'.');">';
            $tabs .= '<p><a href="'. url() .'/gui/' . Request::segment(2) . '/'. $id .'/' . Request::segment(4) . '/ebooks_forex">Ebook Forex';
            $tabs .= '<span class="more"><br />';
            $tabs .= '<i class="hidden-xs cercale glyphicon glyphicon-book fa-3x"></i></span>';
            $tabs .= '</a></p>';
            $tabs .= '</li>';

        }

        if($row == 'chats') {

            $image_ebook = !empty($clients_images_ebook->fullpath) ? $clients_images_ebook->fullpath : url() .'/files/images/chat.jpg';

            $tabs .= '<li class="videos chats" style="background-image: url(' . $image_ebook . '?86400'.');">';
            $tabs .= '<p><a href="'. url() .'/gui/' . Request::segment(2) . '/'. $id .'/' . Request::segment(4) . '/chats">Chat with an expert';
            $tabs .= '<span class="more"><br />';
            $tabs .= '<i class="hidden-xs cercale fa fa-weixin fa-3x"></i></span>';
            $tabs .= '</a></p>';
            $tabs .= '</li>';

        }          

        foreach($idcours as $row2) {

            $lang = !empty(Session::get('local')) ? Session::get('local') : 'gb';
            $showbox = DB::table('mediameneger')->where('course',$row2->id)->where('lang', $lang)->limit(1)->get();
            $clients_images = DB::table('mediameneger')->where('course',$row2->id)->where('type','image')->where('client_id',$id)->first();

            foreach ($showbox as $key) {

                $lang = Session::get('local') != null ? Session::get('local') : Request::segment(2);
                $image = !empty($clients_images->fullpath) ? $clients_images->fullpath : $row2->imagepath;

                $tabs .= '<li class="videos" style="background-image: url('. $image . '?86400' .');">';
                $tabs .= '<p><a href="'. url() .'/gui/' . $lang . '/' . $id .'/' . Request::segment(4) . '/lessons/' . $row2->id . '">' . trans('home.'. $row2->name . '') . '';
                $tabs .= '<span class="more"><i class="text">' . $coursCount . ' ' . trans('home.lessonstotal') .'</i><br />';
                $tabs .= '<i class="hidden-xs cercale glyphicon glyphicon-play fa-3x"></i></span>';
                $tabs .= '</a></p>';
                $tabs .= '</li>'; 

            }

        }
    }

    $tabs .='<li style="overflow: hidden; clear: both; height: 0; position: relative; float: none; display: block;"></li>';

    $data['tabs'] = $tabs;
    $data['IndexCats'] = $IndexCats;
    return $data;
}

错误来自所有爆炸(); 我以前不知道为什么要工作。

2 个答案:

答案 0 :(得分:0)

尝试运行命令“php artisan dump-autoload”和作曲家“dump-autoload”。

答案 1 :(得分:0)

退出您的网站,然后重新登录。这通常会在您单独离开本地开发服务器时发生。