> ## Documentation Index
> Fetch the complete documentation index at: https://kawax.biz/llms.txt
> Use this file to discover all available pages before exploring further.

# Notificatiekanaal - LINE SDK for Laravel

> Notificaties versturen door het Laravel Notification System te integreren met de LINE Messaging API.

## Overzicht

Met `LineChannel` kun je vanuit Laravel Notifications berichten versturen naar LINE.

<Info>
  Omdat de dienst LINE Notify is gestopt, is de ondersteuning voor LINE Notify beëindigd. Notificaties verlopen nu via de Messaging API, waarvoor per tariefplan een limiet op het aantal berichten geldt. Zie de [prijzen van de Messaging API](https://developers.line.biz/ja/docs/messaging-api/pricing/).
</Info>

## De Notification-klasse

Geef in `via()` `LineChannel::class` terug en definieer het bericht in `toLine()`.

```php theme={null}
use Illuminate\Notifications\Notification;
use Revolution\Line\Notifications\LineChannel;
use Revolution\Line\Notifications\LineMessage;

class TestNotification extends Notification
{
    public function via(object $notifiable): array
    {
        return [
            LineChannel::class,
        ];
    }

    public function toLine(object $notifiable): LineMessage
    {
        return LineMessage::create(text: 'test');
    }
}
```

## Verzendpatronen

### On-demand notificaties

Gebruik `Notification::route()` om een notificatie te versturen zonder koppeling aan een usermodel. De bestemming is een `userId` of `groupId`.

```php theme={null}
use Illuminate\Support\Facades\Notification;

Notification::route('line', 'to')
            ->notify(new TestNotification());
```

### Notificaties vanuit het User-model

Definieer `routeNotificationForLine()` als je de bestemming per gebruiker wilt beheren.

```php theme={null}
use Illuminate\Notifications\Notifiable;

class User extends Model
{
    use Notifiable;

    public function routeNotificationForLine($notification): string
    {
        return $this->line_id;
    }
}
```

```php theme={null}
$user->notify(new TestNotification());
```

<Info>
  Je kunt de `userId` of `groupId` ophalen uit webhookevents zoals `FollowEvent` en `JoinEvent`.
</Info>

## Berichttypen

### Tekst

Je kunt maximaal 5 berichten versturen.

```php theme={null}
use Revolution\Line\Notifications\LineMessage;

public function toLine(object $notifiable): LineMessage
{
    return LineMessage::create()
                      ->text('text 1')
                      ->text('text 2');
}
```

### Afzendernaam en icoon aanpassen

`withSender()` moet worden aangeroepen vóór de methods die berichten toevoegen.

```php theme={null}
use Revolution\Line\Notifications\LineMessage;

public function toLine(object $notifiable): LineMessage
{
    return LineMessage::create()
                      ->withSender(name: 'alt-name', icon: 'https://...png')
                      ->text('text 1')
                      ->text('text 2');
}
```

Je kunt de naam en het icoon ook opgeven via de parameters van `create()`.

```php theme={null}
use Revolution\Line\Notifications\LineMessage;

public function toLine(object $notifiable): LineMessage
{
    return LineMessage::create(text: 'test', name: 'alt-name', icon: 'https://...png');
}
```

### Stickers

Zie de [Sticker list](https://developers.line.biz/ja/docs/messaging-api/sticker-list/) voor de beschikbare stickers.

```php theme={null}
use Revolution\Line\Notifications\LineMessage;

public function toLine(object $notifiable): LineMessage
{
    return LineMessage::create()
                      ->text('test')
                      ->sticker(package: 446, sticker: 1988);
}
```

### Afbeeldingen

Geef een openbare URL op.

```php theme={null}
use Revolution\Line\Notifications\LineMessage;

public function toLine(object $notifiable): LineMessage
{
    return LineMessage::create()
                      ->image(original: 'https://.../test.png', preview: 'https://.../preview.png');
}
```

### Video

Geef een openbare URL op.

```php theme={null}
use Revolution\Line\Notifications\LineMessage;

public function toLine(object $notifiable): LineMessage
{
    return LineMessage::create()
                      ->video(original: 'https://.../test.mp4', preview: 'https://.../preview.png');
}
```

### Overige berichttypen

Met `message()` kun je elk willekeurig berichttype toevoegen. Geef het type op met `setType()`.

```php theme={null}
use LINE\Clients\MessagingApi\Model\LocationMessage;
use LINE\Constants\MessageType;
use Revolution\Line\Notifications\LineMessage;

public function toLine(object $notifiable): LineMessage
{
    $location = (new LocationMessage())
        ->setType(MessageType::LOCATION)
        ->setTitle('title')
        ->setAddress('address')
        ->setLatitude(0.0)
        ->setLongitude(0.0);

    return LineMessage::create()
                      ->message($location);
}
```

<Info>
  Zie de [GitHub-repository](https://github.com/invokable/laravel-line-sdk) voor de meest recente informatie.
</Info>


## Related topics

- [LINE SDK for Laravel](/nl/packages/laravel-line-sdk/index.md)
- [Socialite (LINE Login) - LINE SDK for Laravel](/nl/packages/laravel-line-sdk/socialite.md)
- [Webhook / Bot - LINE SDK for Laravel](/nl/packages/laravel-line-sdk/bot.md)
- [Notificatiekanaal - Laravel Bluesky](/nl/packages/laravel-bluesky/notification.md)
- [Bottutorial - Laravel Bluesky](/nl/packages/laravel-bluesky/bot-tutorial.md)
