-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextend.php
38 lines (34 loc) · 1.07 KB
/
extend.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/*
* This file is part of xypp/store-auto-checkin.
*
* Copyright (c) 2024 小鱼飘飘.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace Xypp\StoreAutoCheckin;
use Carbon\Carbon;
use Flarum\Extend;
use Flarum\User\User;
use Xypp\Store\Context\UseContext;
use Xypp\Store\PurchaseHistory;
return [
(new Extend\Frontend('forum'))
->js(__DIR__ . '/js/dist/forum.js'),
new Extend\Locales(__DIR__ . '/locale'),
(new \Xypp\Store\Extend\StoreItemProvider())
->simple("auto-check-in", function (...$_) {
return true;
}, function (PurchaseHistory $item, User $user, string $data, UseContext $context) {
$d = $item->data;
if ($d != "default") {
$a = Carbon::createFromTimestamp($d);
if ($a->isSameDay(Carbon::now())) {
$context->noConsume();
}
}
$item->data = Carbon::now()->getTimestamp();
return true;
})
];