2013-04-04 122 views
0

我正在使用Laravel 3並希望在我的模型中使用Sentry :: user作爲$ include,但它不會讓我。到目前爲止,我已經在$ include中嘗試了「Sentry :: user」,導致「ap $ iw {u []」。我也嘗試過「sentry.user」,但這意味着一個哨兵模型(我沒有)和用戶關係。在模型中使用Laravel包

所以爲了讓這個問題對其他人也有價值:你如何在自己的Laravel 3模型中包含一個模型包?

<?php 
public $includes = array('company', '??'); 

public function company() { 
    return $this->belongs_to('Company'); 
} 

public function user() { 
    return $this->belongs_to('Sentry::user'); 
} 
?> 

回答

0

我以前沒使用哨兵,但如果這種模式是一個哨兵命名空間下的命名空間,那麼你需要完全合格的命名空間提供給模型。例如:

return $this->belongs_to('Sentry\User');