123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Repositories\Models\Wechat;
- use App\Repositories\Enums\ModelStatusEnum;
- use App\Repositories\Models\Model;
- use Carbon\Carbon;
- use Illuminate\Support\Facades\Cache;
- class Event extends Model
- {
- /**
- * @var string
- */
- protected $table = 'wechat_events';
- protected $guarded = [];
- /**
- * The attributes excluded from the model's JSON form.
- *
- * @var array
- */
- protected $hidden = [];
- public static function getSubscribe($account_id)
- {
- return Cache::remember("model:wechat:event:getSubscribe:{$account_id}", Carbon::now()->addDay(), function () use ($account_id) {
- return self::query()->where('account_id', $account_id)->where('type', 'subscribe')->where('status', ModelStatusEnum::OK)->orderByDesc('id')->first();
- });
- }
- public static function getClickEvent($account_id, $key)
- {
- return Cache::remember("model:wechat:event:getClickEvent:{$account_id}:{$key}", Carbon::now()->addDay(), function () use ($account_id, $key) {
- return self::query()->where('account_id', $account_id)->where('type', 'click')->where('event_key', $key)->where('status', ModelStatusEnum::OK)->orderByDesc('id')->first();
- });
- }
- }
|