-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5843d82
commit 9499035
Showing
12 changed files
with
290 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use App\Support\Http\Requests\BaseRequest; | ||
|
||
class FrontUptimeWebhookRequest extends BaseRequest | ||
{ | ||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function rules(): array | ||
{ | ||
return [ | ||
'heartbeat' => ['sometimes', 'nullable', 'required', 'array'], | ||
'monitor' => ['sometimes', 'nullable', 'required', 'array'], | ||
'msg' => ['required',], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use App\Support\ORM\BaseModel; | ||
|
||
class UptimeWebhookCall extends BaseModel | ||
{ | ||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array<int, string> | ||
*/ | ||
protected $fillable = [ | ||
'msg', | ||
'heartbeat', | ||
'monitor', | ||
]; | ||
|
||
/** | ||
* The attributes that should be cast. | ||
* | ||
* @var array<string, string> | ||
*/ | ||
protected $casts = [ | ||
'msg' => 'array', | ||
'heartbeat' => 'array', | ||
'monitor' => 'array', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace App\Notifications; | ||
|
||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Notifications\Notification; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use NotificationChannels\WebPush\WebPushChannel; | ||
use NotificationChannels\WebPush\WebPushMessage; | ||
|
||
class UptimeMonitor extends Notification implements ShouldQueue | ||
{ | ||
use Queueable; | ||
|
||
/** | ||
* Create a new notification instance. | ||
*/ | ||
public function __construct(public string $message) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Get the notification's delivery channels. | ||
* | ||
* @return array<int, string> | ||
*/ | ||
public function via(object $notifiable): array | ||
{ | ||
return [WebPushChannel::class]; | ||
} | ||
|
||
public function toWebPush($notifiable, $notification) | ||
{ | ||
return (new WebPushMessage) | ||
->title($this->message) | ||
->icon(mix('/images/favicons/favicon-192x192.png')) | ||
->body($this->message); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
database/migrations/2024_02_25_170912_add_should_be_notified_to_users_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('users', function (Blueprint $table) { | ||
$table->boolean('should_be_notified')->after('remember_token')->index()->nullable(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('users', function (Blueprint $table) { | ||
$table->dropIndex(['should_be_notified']); | ||
$table->dropColumn('should_be_notified'); | ||
}); | ||
} | ||
}; |
34 changes: 34 additions & 0 deletions
34
database/migrations/2024_02_25_171245_create_uptime_webhook_calls_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::create('uptime_webhook_calls', function (Blueprint $table) { | ||
$table->id(); | ||
$table->json('msg'); | ||
$table->json('heartbeat'); | ||
$table->json('monitor'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('uptime_webhook_calls'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.