2014-11-02 84 views
0

我正在使用Laravel 4.2 &在我的生產服務器上出現Class 'Setting' not found錯誤,而它在我的本地主機上運行正常。這裏是我的控制器代碼(部分)Laravel - 'Setting'找不到

這裏是我的控制器代碼:

<?php 
// app/controllers/ClaimController.php 
class ClaimController extends \BaseController { 
    public function create() 
    { 
    $insurers  = Insurer::lists('insurers_name', 'id'); 
    $office   = Office::lists('office_name', 'id'); 
    $workshops  = Workshop::lists('workshop_name', 'id'); 
    $type_of_report = Setting::where('grp','=','type_of_report')->lists('name','id'); 
    $vehicle_type = Setting::where('grp','=','vehicle_type')->lists('name','id'); 

    return View::make('claim.create')->with('insurers',$insurers)->with('office',$office)->with('workshops',$workshops)->with('type_of_report', $type_of_report)->with('vehicle_type', $vehicle_type); 
    } 
} 

型號代碼:

<?php 
// app/models/setting.php 
    class Setting extends Eloquent { 
    } 
?> 

收到此錯誤

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_ERROR) 
Class 'Setting' not found 

當我改變 上面兩行創建()函數來

$type_of_report = DB::table('settings')->where('grp','type_of_report')->lists('name','id'); 
$vehicle_type = DB::table('settings')->where('grp','vehicle_type')->lists('name','id'); 

在我的本地工作的生產服務器上&罰款。

+0

您確定這不是設置的拼寫錯誤嗎? – Prasanth 2014-11-02 06:16:42

+0

是的,我重新檢查過,這不是一種類型。 – Aman 2014-11-02 06:23:40

+0

你有設置表的相應模型文件嗎? – Prasanth 2014-11-02 06:28:54

回答

2

問題可能是您的模型文件被命名爲setting.php,它應該是大寫字母Setting.php。在本地主機上(可能是Windows),它將工作沒有問題,因爲在Windows文件aaaAAA是相同的,但在Linux中它不是。

+0

非常感謝@marcin寶貴的建議。我將Setting.php更名爲setting.php,但沒有運氣。仍然得到相同的錯誤。 – Aman 2014-11-02 14:42:41

+0

@Aman它應該和你的類名一樣。你的班級名稱是「Setting」,因此該文件的名稱應該是'Setting.php',現在你告訴你有相反的了。 – 2014-11-02 17:31:03

+0

非常感謝你@Marcin。問題已解決。 – Aman 2014-11-07 09:27:27