<?php
namespace App\Laravel\Database\Eloquent;
use Illuminate\Database\Eloquent\Model;
abstract class CachedModel extends Model
{
/**
* @param \Illuminate\Database\Query\Builder $query
* @return CachedBuilder|\Illuminate\Database\Eloquent\Builder|static
*/
public function newEloquentBuilder($query)
{
return new CachedBuilder($query);
}
}
1条答案
按热度按时间ymzxtsji1#
我需要扩展
Illuminate\Database\Eloquent\Model
和Illuminate\Database\Eloquent\Builder
。我的扩展Builder类
我的扩展Model类
现在我只需要用这个新的CachedModel类扩展我的任何模型,以应用总计数结果的缓存。