extended UploadRequestFulfilledNotification with array

This commit is contained in:
Čarodej
2022-03-10 07:13:38 +01:00
parent 26f7cdb80f
commit 4315cddcb2
2 changed files with 46 additions and 7 deletions

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->string('notifiable_type');
$table->uuid('notifiable_id');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('notifications');
}
};

View File

@@ -1,4 +1,5 @@
<?php
namespace Domain\UploadRequest\Notifications;
use Illuminate\Bus\Queueable;
@@ -18,8 +19,7 @@ class UploadRequestFulfilledNotification extends Notification implements ShouldQ
*/
public function __construct(
public UploadRequest $uploadRequest
) {
}
) {}
/**
* Get the notification's delivery channels.
@@ -29,7 +29,7 @@ class UploadRequestFulfilledNotification extends Notification implements ShouldQ
*/
public function via($notifiable)
{
return ['mail'];
return ['mail', 'database'];
}
/**
@@ -51,13 +51,16 @@ class UploadRequestFulfilledNotification extends Notification implements ShouldQ
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
public function toArray(mixed $notifiable): array
{
return [
'type' => 'file-request',
'title' => 'File Request Filled',
'description' => "Your file request for '{$this->uploadRequest->parent->name}' folder was filled successfully.",
'action' => [
'id' => $this->uploadRequest->id,
],
];
}
}