Laravel在composer更新模型方法后调用undefined


Laravel after composer update model method call undefined

我正在用Laravel 4.2做一个项目,我创建了一些模型和控制器,并从控制器调用了模型函数,问题是在composer update命令之后,它显示了这个错误:Call to undefined method Department::getAllParent(),但在composer update之前,它工作得很好。你觉得这个问题出在哪里?提前感谢

型号代码:

class Department extends Eloquent{
    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'department';
    public static function getAll()
    {
        $table = DB::table('department');
        $object = $table->get();
        return $object;
    }
    public static function getAllParent()
    {
        $table = DB::table('department');
        $table->where('parent',0);
        $object = $table->get();
        return $object;
    }
}

控制器代码:

class DepartmentController extends BaseController
{
    /*
    Getting all records from department
    @param: none
    @Accessiblity: public
    @return: Object
    */
    public function getAllDepartment()
    {
        //get data from model
        $deps = Department::getAllParent();
        $depAll = Department::getAll();
        //load view for users list
        return View::make("department.dep_list")->with('deps',$deps)->with('all',$depAll);
    }
}

不要认为这与您的问题有关,但这可能是处理这些查询的更好方法。您正在使用Eloquent并设置表参数。为什么不利用Eloquent的内在力量呢?

class Department extends Eloquent{
    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'department';
    public static function getAll()
    {
        return Department::get();
    }
    public static function getAllParent()
    {
        return Department::where('parent', 0)->get();
    }
}

我想你也可以使用$this->get();,但我现在不能测试。