1. Go to this page and download the library: Download ruvelo/laravel-inbox library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ruvelo / laravel-inbox example snippets
class InvoicePaid extends Notification
{
public function via(object $notifiable): array
{
return ['mail', 'database'];
}
public function toArray(object $notifiable): array
{
return [
'title' => "Invoice {$this->invoice->number} paid",
'body' => "{$this->invoice->customer} paid {$this->invoice->total}.",
'url' => route('invoices.show', $this->invoice),
'icon' => '💸',
];
}
}
use Ruvelo\Inbox\Contracts\InboxNotification;
use Ruvelo\Inbox\InboxMessage;
class TeammateJoined extends Notification implements InboxNotification
{
public function via(object $notifiable): array
{
return ['database'];
}
public function toInbox(object $notifiable): InboxMessage
{
return InboxMessage::make("{$this->user->name} joined your team")
->withUrl(route('team'))
->withActor($this->user->name);
}
}
use Ruvelo\Inbox\Inbox;
Inbox::preferences([
InvoicePaid::class => [
'label' => 'Invoice paid',
'description' => 'When a customer pays one of your invoices.',
'group' => 'Billing',
'channels' => ['mail', 'database'],
'defaults' => ['mail' => false], // off until they turn it on
],
SecurityAlert::class => [
'label' => 'Security alerts',
'channels' => ['mail'],
'
use Ruvelo\Inbox\Notifications\RespectsInboxPreferences;
class InvoicePaid extends Notification
{
use RespectsInboxPreferences;
public function via(object $notifiable): array
{
return $this->preferredChannels($notifiable, ['mail', 'database']);
}
}