Skip to content

Commit b4775e8

Browse files
committed
add support for laravel 8, added mail-viewer:publish command to follow Laravel conventions and simplify usage
1 parent 6eb0078 commit b4775e8

File tree

5 files changed

+106
-60
lines changed

5 files changed

+106
-60
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This will bootstrap the package into Laravel.
2828
### Step 3: Publish Configs
2929

3030
```
31-
php artisan vendor:publish --provider="MasterRO\MailViewer\Providers\MailViewerServiceProvider"
31+
php artisan mail-viewer:publish"
3232
```
3333

3434
You have to publish _**assets,**_ and _**views,**_ _configs_ are optional.
@@ -41,4 +41,4 @@ php artisan migrate
4141
```
4242

4343
### Step 5: View emails
44-
All ongoing emails would be displayed on `/_mail-viewer` page by default.
44+
All ongoing emails you can find on `/_mail-viewer` page. Url

composer.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515
"log"
1616
],
1717
"require": {
18-
"illuminate/support": "^5.5|^6.0|^7.0",
19-
"illuminate/events": "^5.5|^6.0|^7.0",
20-
"illuminate/database": "^5.5|^6.0|^7.0",
21-
"illuminate/routing": "^5.5|^6.0|^7.0",
22-
"illuminate/mail": "^5.5|^6.0|^7.0"
18+
"illuminate/support": "^5.5|^6.0|^7.0|^8.0",
19+
"illuminate/events": "^5.5|^6.0|^7.0|^8.0",
20+
"illuminate/database": "^5.5|^6.0|^7.0|^8.0",
21+
"illuminate/routing": "^5.5|^6.0|^7.0|^8.0",
22+
"illuminate/mail": "^5.5|^6.0|^7.0|^8.0"
2323
},
2424
"require-dev": {
25-
"orchestra/testbench": "^3.5,<3.9",
26-
"phpunit/phpunit": "^6.5"
25+
"orchestra/testbench": "^3.5|v4.0|v5.0||v6.0"
2726
},
2827
"autoload": {
2928
"psr-4": {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MasterRO\MailViewer\Commands;
6+
7+
use Illuminate\Console\Command;
8+
9+
/**
10+
* Class PublishCommand
11+
*
12+
* @package MasterRO\MailViewer\Commands
13+
*/
14+
class PublishCommand extends Command
15+
{
16+
protected $signature = 'mail-viewer:publish {--views : Also publish mail-viewer views}';
17+
18+
protected $description = 'Publish mail-viewer assets configs and optionally views.';
19+
20+
public function handle()
21+
{
22+
$this->call('vendor:publish', [
23+
'--tag' => 'mail-viewer-assets',
24+
'--force' => true,
25+
]);
26+
27+
$this->call('vendor:publish', [
28+
'--tag' => 'mail-viewer-config',
29+
]);
30+
31+
if ($this->option('views')) {
32+
$this->call('vendor:publish', [
33+
'--tag' => 'mail-viewer-views',
34+
'--force' => true,
35+
]);
36+
}
37+
}
38+
}
File renamed without changes.

src/app/Providers/MailViewerServiceProvider.php

Lines changed: 60 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,68 @@
44

55
use Illuminate\Mail\Events\MessageSending;
66
use MasterRO\MailViewer\Listeners\MailLogger;
7+
use MasterRO\MailViewer\Commands\PublishCommand;
78
use Illuminate\Foundation\Support\Providers\EventServiceProvider;
89

910
class MailViewerServiceProvider extends EventServiceProvider
1011
{
11-
/**
12-
* The event handler mappings for the application.
13-
*
14-
* @var array
15-
*/
16-
protected $listen = [
17-
MessageSending::class => [
18-
MailLogger::class,
19-
],
20-
];
21-
22-
23-
/**
24-
* Boot the service provider.
25-
*
26-
* @return void
27-
*/
28-
public function boot()
29-
{
30-
parent::boot();
31-
32-
$this->publish();
33-
34-
$this->mergeConfigFrom(
35-
__DIR__ . '/../../config/mail-viewer.php', 'mail-viewer'
36-
);
37-
38-
$this->loadMigrationsFrom(__DIR__ . '/../../database/migrations/');
39-
40-
$this->loadRoutesFrom(__DIR__ . '/../../resources/routes/web.php');
41-
42-
$this->loadViewsFrom(__DIR__ . '/../../resources/views', 'mail-viewer');
43-
}
44-
45-
/**
46-
* Publish config, views and assets
47-
*/
48-
protected function publish()
49-
{
50-
$this->publishes([
51-
__DIR__ . '/../../config/mail-viewer.php' => config_path('mail-viewer.php'),
52-
], 'mail-viewer-config');
53-
54-
$this->publishes([
55-
__DIR__ . '/../../resources/views' => resource_path('views/vendor/mail-viewer'),
56-
], 'mail-viewer-views');
57-
58-
$this->publishes([
59-
__DIR__ . '/../../public/' => public_path('vendor/mail-viewer'),
60-
], 'mail-viewer-assets');
61-
}
12+
/**
13+
* The event handler mappings for the application.
14+
*
15+
* @var array
16+
*/
17+
protected $listen = [
18+
MessageSending::class => [
19+
MailLogger::class,
20+
],
21+
];
22+
23+
public function register()
24+
{
25+
parent::register();
26+
27+
$this->commands([
28+
PublishCommand::class,
29+
]);
30+
}
31+
32+
/**
33+
* Boot the service provider.
34+
*
35+
* @return void
36+
*/
37+
public function boot()
38+
{
39+
parent::boot();
40+
41+
$this->publish();
42+
43+
$this->mergeConfigFrom(
44+
__DIR__ . '/../../config/mail-viewer.php', 'mail-viewer'
45+
);
46+
47+
$this->loadMigrationsFrom(__DIR__ . '/../../database/migrations/');
48+
49+
$this->loadRoutesFrom(__DIR__ . '/../../resources/routes/web.php');
50+
51+
$this->loadViewsFrom(__DIR__ . '/../../resources/views', 'mail-viewer');
52+
}
53+
54+
/**
55+
* Publish config, views and assets
56+
*/
57+
protected function publish()
58+
{
59+
$this->publishes([
60+
__DIR__ . '/../../config/mail-viewer.php' => config_path('mail-viewer.php'),
61+
], 'mail-viewer-config');
62+
63+
$this->publishes([
64+
__DIR__ . '/../../resources/views' => resource_path('views/vendor/mail-viewer'),
65+
], 'mail-viewer-views');
66+
67+
$this->publishes([
68+
__DIR__ . '/../../public/' => public_path('vendor/mail-viewer'),
69+
], 'mail-viewer-assets');
70+
}
6271
}

0 commit comments

Comments
 (0)