1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Spatie\Backup\Notifications; |
4
|
|
|
|
5
|
|
|
use Illuminate\Notifications\Notification; |
6
|
|
|
use Illuminate\Support\Collection; |
7
|
|
|
use Spatie\Backup\Helpers\Format; |
8
|
|
|
|
9
|
|
|
abstract class BaseNotification extends Notification |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Get the notification's delivery channels. |
13
|
|
|
* |
14
|
|
|
* @param mixed $notifiable |
|
|
|
|
15
|
|
|
* @return array |
16
|
|
|
*/ |
17
|
|
|
public function via() |
18
|
|
|
{ |
19
|
|
|
return config('laravel-backup.notifications.notifications.'.static::class); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function applicationName(): string |
23
|
|
|
{ |
24
|
|
|
return config('app.name'); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function diskName(): string |
28
|
|
|
{ |
29
|
|
|
return $this->backupDestination()->diskName(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
protected function backupDestinationProperties(): Collection |
33
|
|
|
{ |
34
|
|
|
$backupDestination = $this->backupDestination(); |
35
|
|
|
|
36
|
|
|
if (! $backupDestination) { |
37
|
|
|
return collect(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
$newestBackup = $backupDestination->newestBackup(); |
41
|
|
|
$oldestBackup = $backupDestination->oldestBackup(); |
42
|
|
|
|
43
|
|
|
return collect([ |
44
|
|
|
'Application name' => $this->applicationName(), |
45
|
|
|
'Disk' => $backupDestination->diskName(), |
46
|
|
|
'Newest backup size' => $newestBackup ? Format::humanReadableSize($newestBackup->size()) : 'No backups were made yet', |
47
|
|
|
'Amount of backups' => $backupDestination->backups()->count(), |
48
|
|
|
'Total storage used' => Format::humanReadableSize($backupDestination->backups()->size()), |
49
|
|
|
'Newest backup date' => $newestBackup ? $newestBackup->date()->format('Y/m/d H:i:s') : 'No backups were made yet', |
50
|
|
|
'Oldest backup date' => $oldestBackup ? $oldestBackup->date()->format('Y/m/d H:i:s') : 'No backups were made yet', |
51
|
|
|
])->filter(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return \Spatie\Backup\BackupDestination\BackupDestination|null |
56
|
|
|
*/ |
57
|
|
|
public function backupDestination() |
58
|
|
|
{ |
59
|
|
|
if (isset($this->event->backupDestination)) { |
60
|
|
|
return $this->event->backupDestination; |
|
|
|
|
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
if (isset($this->event->backupDestinationStatus)) { |
64
|
|
|
return $this->event->backupDestinationStatus->getBackupDestination(); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.