Skip to content

Commit 0a9af3c

Browse files
Merge pull request #1 from stackkit/development
2.0.0
2 parents 6e9022b + fab1cfb commit 0a9af3c

32 files changed

+1428
-548
lines changed

.travis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
language: php
22

33
php:
4-
- 5.6
54
- 7.0
65
- 7.1
76

87
sudo: false
98

109
install: travis_retry composer install --no-interaction --prefer-source
1110

12-
script: vendor/bin/phpunit --verbose
11+
script: vendor/bin/phpunit --verbose

README.md

+48-21
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
## Introduction
1111

12-
This is a package that stores and queues e-mails using a database table. Easily send e-mails using a cronjob or schedule e-mails that should be sent at a specific date and time.
12+
This is a package that stores and queues e-mails using a database table. Easily send e-mails using a cronjob and schedule e-mails that should be sent at a specific date and time.
1313
## Installation
1414

1515
First, require the package using composer.
@@ -24,16 +24,15 @@ If you're running Laravel 5.5 or later you may skip this step. Add the service p
2424
Buildcode\LaravelDatabaseEmails\LaravelDatabaseEmailsServiceProvider::class,
2525
```
2626

27-
Publish the configuration file.
27+
Publish the configuration files.
2828

2929
```bash
3030
$ php artisan vendor:publish --provider=Buildcode\\LaravelDatabaseEmails\\LaravelDatabaseEmailsServiceProvider
3131
```
3232

33-
Create the e-mails database table migration.
33+
Create the database table required for this package.
3434

3535
```bash
36-
$ php artisan email:table
3736
$ php artisan migrate
3837
```
3938

@@ -57,7 +56,7 @@ protected function schedule(Schedule $schedule)
5756
### Create An Email
5857

5958
```php
60-
Buildcode\LaravelDatabaseEmails\Email::compose()
59+
Email::compose()
6160
->label('welcome-mail-1.0')
6261
->recipient('[email protected]')
6362
->subject('This is a test')
@@ -68,20 +67,53 @@ Buildcode\LaravelDatabaseEmails\Email::compose()
6867
->send();
6968
```
7069

70+
### Specify Recipients
71+
72+
```php
73+
74+
75+
76+
Email::compose()->recipient($one);
77+
Email::compose()->recipient($multiple);
78+
79+
Email::compose()->cc($one);
80+
Email::compose()->cc($multiple);
81+
82+
Email::compose()->bcc($one);
83+
Email::compose()->bcc($multiple);
84+
```
85+
86+
### Mailables
87+
88+
You may also pass a mailable to the e-mail composer.
89+
90+
```php
91+
Email::compose()
92+
->mailable(new OrderShipped())
93+
->send();
94+
```
95+
96+
### Attachments
97+
98+
```php
99+
Email::compose()
100+
->attach('/path/to/file');
101+
```
102+
103+
Or for in-memory attachments...
104+
105+
```php
106+
Email::compose()
107+
->attachData('<p>Your order has shipped!</p>', 'order.html');
108+
```
109+
71110
### Schedule An Email
72111

73-
You may schedule an e-mail by calling `schedule` instead of `send` at the end of the chain. You must provide a Carbon instance or a strtotime valid date.
112+
You may schedule an e-mail by calling `later` instead of `send` at the end of the chain. You must provide a Carbon instance or a strtotime valid date.
74113

75114
```php
76-
Buildcode\LaravelDatabaseEmails\Email::compose()
77-
->label('welcome-mail-1.0')
78-
->recipient('[email protected]')
79-
->subject('This is a test')
80-
->view('emails.welcome')
81-
->variables([
82-
'name' => 'John Doe',
83-
])
84-
->schedule('+2 hours');
115+
Email::compose()
116+
->later('+2 hours');
85117
```
86118

87119
### Manually Sending E-mails
@@ -112,11 +144,6 @@ If you wish to encrypt your e-mails, please enable the `encrypt` option in the c
112144

113145
### Testing Address
114146

115-
If you wish to send e-mails to a test address but don't necessarily want to use a service like mailtrap, please take a look at the `testing` configuration. This is turned on by default.
147+
If you wish to send e-mails to a test address but don't necessarily want to use a service like mailtrap, please take a look at the `testing` configuration. This is turned off by default.
116148

117149
During the creation of an e-mail, the recipient will be replaced by the test e-mail. This is useful for local development or testing on a staging server.
118-
119-
## Todo
120-
121-
- Add support for attachments
122-
- Add support for Mailables

composer.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88
"email": "[email protected]"
99
}
1010
],
11-
"require": {
12-
"illuminate/database": "^5.2",
13-
"illuminate/console": "^5.2",
14-
"illuminate/validation": "^5.2"
15-
},
1611
"autoload": {
1712
"psr-4": {
1813
"Buildcode\\LaravelDatabaseEmails\\": "src/"
@@ -31,8 +26,13 @@
3126
}
3227
},
3328
"require-dev": {
34-
"orchestra/testbench": "~3.4",
35-
"phpunit/phpunit": "^5.7",
36-
"orchestra/database": "~3.4"
29+
"illuminate/database": "^5.5",
30+
"illuminate/console": "^5.5",
31+
"illuminate/validation": "^5.5",
32+
"orchestra/testbench": "^3.5",
33+
"orchestra/database": "^3.5",
34+
"phpunit/phpunit": "^6.0",
35+
"mockery/mockery": "^1.0",
36+
"dompdf/dompdf": "^0.8.2"
3737
}
3838
}

config/laravel-database-emails.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@
4848
'email' => '[email protected]',
4949

5050
'enabled' => function () {
51-
return app()->environment('local', 'staging');
51+
return false;
52+
// ...or...
53+
// return app()->environment('local', 'staging');
5254
}
5355

5456
],

database/migrations/emails.stub renamed to database/migrations/2017_12_14_151403_create_emails_table.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Database\Migrations\Migration;
66

7-
class Create{{tableClassName}}Table extends Migration
7+
class CreateEmailsTable extends Migration
88
{
99
/**
1010
* Run the migrations.
@@ -13,7 +13,11 @@ class Create{{tableClassName}}Table extends Migration
1313
*/
1414
public function up()
1515
{
16-
Schema::create('{{table}}', function (Blueprint $table) {
16+
if (Schema::hasTable('emails')) {
17+
return;
18+
}
19+
20+
Schema::create('emails', function (Blueprint $table) {
1721
$table->increments('id');
1822
$table->string('label')->nullable();
1923
$table->binary('recipient');
@@ -43,6 +47,6 @@ public function up()
4347
*/
4448
public function down()
4549
{
46-
Schema::dropIfExists('{{table}}');
50+
//
4751
}
4852
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class AddAttachmentsToEmailsTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
if (Schema::hasColumn('emails', 'attachments')) {
17+
return;
18+
}
19+
20+
Schema::table('emails', function (Blueprint $table) {
21+
$table->binary('attachments')->after('body')->default('');
22+
});
23+
}
24+
25+
/**
26+
* Reverse the migrations.
27+
*
28+
* @return void
29+
*/
30+
public function down()
31+
{
32+
//
33+
}
34+
}

src/Config.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Config
99
*
1010
* @return int
1111
*/
12-
public static function maxRetryCount()
12+
public static function maxAttemptCount()
1313
{
1414
return max(config('laravel-database-emails.retry.attempts', 1), 3);
1515
}
@@ -59,4 +59,4 @@ public static function cronjobEmailLimit()
5959
{
6060
return config('laravel-database-emails.limit', 20);
6161
}
62-
}
62+
}

src/CreateEmailTableCommand.php

-112
This file was deleted.

src/Decorators/EmailDecorator.php

-8
This file was deleted.

0 commit comments

Comments
 (0)