psr-4 autoload - 无法重新声明课程

时间:2014-03-30 17:45:12

标签: php laravel-4 psr-4

我正在尝试使用Laravel第一次使用psr-4自动加载。在我使用模型后,我有以下雄辩的模型:

<?php namespace Models\Series;

class Player extends \BaseModel {}

它工作正常,但如果我添加这样的集合:

public static function listing()
{
    return Player::paginate(15);
}

然后我收到此错误:

Cannot redeclare class Models\Series\Player

我也尝试用Player::paginate(15)替换self::paginate(15),但无济于事。

1 个答案:

答案 0 :(得分:0)

而不是在模型中使用静态函数,为什么不尝试使用范围

namespace Models\Series;

class Player extends \BaseModel {

    public function scopeListing($query){
        return $query->paginate(15);
    }
}

我还没有测试过,但我希望我会帮忙:D