mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 20:40:49 +08:00
exam recurring add daily + TorrentDeleted event
This commit is contained in:
38
app/Events/TorrentDeleted.php
Normal file
38
app/Events/TorrentDeleted.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class TorrentDeleted
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public int $torrentId;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(int $torrentId)
|
||||
{
|
||||
$this->torrentId = $torrentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new PrivateChannel('channel-name');
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,7 @@ class Exam extends NexusModel
|
||||
self::FILTER_USER_REGISTER_DAYS_RANGE => ['name' => 'User register days range'],
|
||||
];
|
||||
|
||||
const RECURRING_DAILY = "Daily";
|
||||
const RECURRING_WEEKLY = "Weekly";
|
||||
const RECURRING_MONTHLY = "Monthly";
|
||||
|
||||
@@ -93,6 +94,7 @@ class Exam extends NexusModel
|
||||
public static function listRecurringOptions(): array
|
||||
{
|
||||
return [
|
||||
self::RECURRING_DAILY => nexus_trans("exam.recurring_daily"),
|
||||
self::RECURRING_WEEKLY => nexus_trans("exam.recurring_weekly"),
|
||||
self::RECURRING_MONTHLY => nexus_trans("exam.recurring_monthly"),
|
||||
];
|
||||
@@ -215,6 +217,8 @@ class Exam extends NexusModel
|
||||
return $time->startOfWeek();
|
||||
} elseif ($recurring == self::RECURRING_MONTHLY) {
|
||||
return $time->startOfMonth();
|
||||
} elseif ($recurring == self::RECURRING_DAILY) {
|
||||
return $time->startOfDay();
|
||||
}
|
||||
throw new \RuntimeException("Invalid recurring: $recurring");
|
||||
}
|
||||
@@ -226,6 +230,8 @@ class Exam extends NexusModel
|
||||
return $time->endOfWeek();
|
||||
} elseif ($recurring == self::RECURRING_MONTHLY) {
|
||||
return $time->endOfMonth();
|
||||
} elseif ($recurring == self::RECURRING_DAILY) {
|
||||
return $time->endOfDay();
|
||||
}
|
||||
throw new \RuntimeException("Invalid recurring: $recurring");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user