Laravel model scope function names

2019-09-10 03:07发布

问题:

While creating a scope function with name 'scopeList' in the Model to return a data collection (has select) laravel throws a T_List error. Can I know why?

My code:

namespace project1;
use Illuminate\Database\Eloquent\Model;

class Lookup extends Model
{
    protected $fillable = array('type','code','description','listorder');
    public $timestamps = false;

    /**
     * List lookup entries for a given type
     *
     * @param $type
     *
     * @return \Illuminate\Support\Collection
     */
    public function scopeEntries($query,$type){
        return $query->select('code','description')
            ->where('type',$type)->get();
    }
}

If instead of 'scopeEntries', I want to call it 'scopeList' I encounter an error.

标签: laravel-5.1