Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kawax committed Oct 7, 2024
1 parent 0e6eb6c commit 130cca9
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 33 deletions.
16 changes: 16 additions & 0 deletions app/Http/Controllers/NotificationController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\Http\Controllers;

use App\Notifications\LineTest;
use Illuminate\Http\Request;

class NotificationController extends Controller
{
public function __invoke(Request $request)
{
$request->user()->notify(new LineTest('Notification from LINE Messaging API'));

return back();
}
}
5 changes: 5 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ public function routeNotificationForLineNotify($notification)
{
return $this->notify_token;
}

public function routeNotificationForLine($notification)
{
return $this->line_id;
}
}
42 changes: 42 additions & 0 deletions app/Notifications/LineTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
use Revolution\Line\Notifications\LineChannel;
use Revolution\Line\Notifications\LineMessage;

class LineTest extends Notification
{
use Queueable;

/**
* Create a new notification instance.
*
* @param string $message
* @return void
*/
public function __construct(protected string $message)
{
//
}

/**
* Get the notification's delivery channels.
*/
public function via(object $notifiable): array
{
return [
LineChannel::class,
];
}

public function toLine(object $notifiable): LineMessage
{
return LineMessage::create()
->text($this->message)
->sticker(446, random_int(1988, 2027));
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"laravel/framework": "^11.0",
"laravel/socialite": "^5.6",
"laravel/tinker": "^2.0",
"revolution/laravel-line-sdk": "^3.0"
"revolution/laravel-line-sdk": "^3.3"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^3.0",
Expand Down
64 changes: 32 additions & 32 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions resources/views/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
</a>
</div>
</div>

<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 bg-white border-b border-gray-200">
<a href="{{ route('notification') }}" class="underline">
Notification from LINE Messaging API
</a>
</div>
</div>
</div>
</div>
</x-app-layout>
4 changes: 4 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use App\Http\Controllers\LoginController;
use App\Http\Controllers\NotificationController;
use App\Http\Controllers\NotifyController;
use App\Http\Controllers\PushController;
use Illuminate\Support\Facades\Route;
Expand All @@ -26,6 +27,9 @@
Route::get('push', PushController::class)
->name('push');

Route::get('notification', NotificationController::class)
->name('notification');

Route::get('info', function () {
dump(Bot::getBotInfo());
dump(Bot::verifyWebhook());
Expand Down

0 comments on commit 130cca9

Please sign in to comment.