命名空间在Laravel中不起作用

时间:2014-12-24 12:15:32

标签: php class laravel namespaces

您好我有一个名为' Event'

的模型

/app/models/DC/Events/Event.php

<?php
namespace models\DC\Events;

class Event extends \Eloquent {

    protected $table = 'Events';

    protected $guarded = array('id', 'password_confirmation');
    protected $fillable = [
        'name', 
        'adress', 
        'zipcode', 
        'time', 
        'date', 
        'Fee', 
        'link', 
        'Description', 
        'country', 
        'city', 
        'fblink', 
        'lineup'
        ];
}

/app/controllers/EventController.php

<?php

use \models\DC\Events\Event as S;

class EventController extends \BaseController {


    /**
     * Display a listing of the resource.
     * GET /events
     *
     * @return Response
     */
    public function index()
    {
        $events = S::all();
        $events = S::paginate(5);
        return View::make('events.index');
    }
}

但它告诉我&#34; Class&#39; models \ DC \ Events \ Event&#39;找不到&#34;

有关解决方案的建议还是有更好的方法?

1 个答案:

答案 0 :(得分:1)

为了更新自动加载文件以确保所有类都包含在内,您需要运行

composer dump-autoload