| 123456789101112131415161718192021222324252627282930 | <?phpnamespace App\Modules\Book\Models;use Illuminate\Database\Eloquent\Model;use DB;class ChapterComments extends Model{    protected  $table = 'chapter_comments';    protected  $fillable = ['id','bid','tags','chapter','uid'];    public static function addComments($param){        $sign = ['uid'=>$param['uid'],'chapter'=>$param['chapter']];        $update = ['tags'=>$param['tags'],'bid'=>$param['bid']];        return self::updateOrCreate($sign,$update);    }    public static function getChapterComment($cid,$uid){        return self::where([            ['chapter','=',$cid],['uid','=',$uid]        ])->first();    }    public static function getBookStats(){        self::select(DB::raw('sum(uv) as UV,count('))            ->leftjoin('book_configs','book_configs.bid','=','chapter_comments.bid')            ->groupBy('chapter_comments.bid')            ->get();    }}
 |