2014-04-09 26 views
0

我已經創建以下控制器:打開購物車如何獲取當前客戶信息?

class ControllerCommonTestSMS extends Controller 
{ 
    function index() 
    { 
     // action 
    } 
} 

但是,如果我添加以下行,它拋出一個錯誤,該函數未定義:

$this->customer->isLogged(); 
+1

你在哪裏添加了這一行?管理員或前端?沒有客戶登錄檢查,一切正常嗎? –

+0

@rusly他沒有訪問控制的問題(和它的索引操作),他要檢查客戶是否登錄的問題,您的評論是沒有用的... – shadyyx

+1

作爲@SankarV在問 - 你在說什麼前端或後端(管理)控制器?在**前端**您可以在**後端調用'$ this-> customer-> isLogged();'您只能調用'$ this-> user-> isLogged();'... – shadyyx

回答

-2
class ControllerCommonTestSMS extends Controller 
{ 
    function index() 
    { 
     if (!$this->customer->isLogged()) { 

     //code to be execu 

     } 
    } 
} 

這是工作的罰款。

+2

該OP明確表示調用此方法會引發錯誤。說它對你有用不是一個答案,而是請描述*爲什麼*以及它在什麼情況下「起作用」。 – mabi

相關問題