Repository: laravel-shift/blueprint (php)

Issue:
Mailable should generate its template file
### Synopsis:
Currently a mailable generates template with this:
```php
        return $this->view('view.name');
```
I think it could be useful to generate the relevant template file too.

### Proposed Syntax:
currently existing syntax could remain unchanged, or can be extended with a parameter, like `view:email.reviewPost`
```yaml
      send: ReviewPost to:post.author with:post
```

### Expected Behavior:
- add an optional parameter to `send` statement (view). default value could be `email.{mail}`.
- generate a view for this view path, if not exists.
- pass the notification's parameters to the view, and maybe have a parameter hint at the begining of the view's file

Pull request description:
Generate mail views
This updates Blueprint to generate an empty Blade template for any generated Mailable. By default, the kebab case of the Mailable name is used and stored under the `resources/views/emails` folder. You may customize the template name (and path) by passing an optional `view` argument to the `send` statement.

Example:
```yaml
    send: ReviewPost to:post.author with:foo, bar, baz view:emails.posts.review
```

Note: This also contains a change to the `SendStatement` constructor to add the new argument as well as fix a PHP 8 warning about the order of optional arguments.

---
Closes #506

Patch:
diff --git a/src/Generators/Statements/MailGenerator.php b/src/Generators/Statements/MailGenerator.php
index 347aeb0..b523ba0 100644
--- a/src/Generators/Statements/MailGenerator.php
+++ b/src/Generators/Statements/MailGenerator.php
@@ -14,12 +14,13 @@ class MailGenerator extends StatementGenerator
     public function output(Tree $tree): array
     {
         $stub = $this->filesystem->stub('mail.stub');
+        $view_stub = $this->filesystem->stub('mail.view.stub');
 
         /**
          * @var \Blueprint\Models\Controller $controller
          */
         foreach ($tree->controllers() as $controller) {
-            foreach ($controller->methods() as $method => $statements) {
+            foreach ($controller->methods() as $statements) {
                 foreach ($statements as $statement) {
                     if (!$statement instanceof SendStatement) {
                         continue;
@@ -30,12 +31,18 @@ class MailGenerator extends StatementGenerator
                     }
 
                     $path = $this->getStatementPath($statement->mail());
-
                     if ($this->filesystem->exists($path)) {
                         continue;
                     }
 
                     $this->create($path, $this->populateStub($stub, $statement));
+
+                    $path = $this->getViewPath($statement->view());
+                    if ($this->filesystem->exists($path)) {
+                        continue;
+                    }
+
+                    $this->create($path, $this->populateViewStub($view_stub, $statement));
                 }
             }
         }
@@ -43,6 +50,16 @@ class MailGenerator extends StatementGenerator
         return $this->output;
     }
 
+    private function populateViewStub(string $stub, SendStatement $statement)
+    {
+        return str_replace('{{ class }}', $statement->mail(), $stub);
+    }
+
+    private function getViewPath($view)
+    {
+        return 'resources/views/' . str_replace('.', '/', $view) . '.blade.php';
+    }
+
     protected function getStatementPath(string $name)
     {
         return Blueprint::appPath() . '/Mail/' . $name . '.php';
@@ -52,6 +69,7 @@ class MailGenerator extends StatementGenerator
     {
         $stub = str_replace('{{ namespace }}', config('blueprint.namespace') . '\\Mail', $stub);
         $stub = str_replace('{{ class }}', $sendStatement->mail(), $stub);
+        $stub = str_replace('{{ view }}', $sendStatement->view(), $stub);
         $stub = str_replace('{{ properties }}', $this->populateConstructor('message', $sendStatement), $stub);
 
         if (Blueprint::useReturnTypeHints()) {
diff --git a/src/Lexers/StatementLexer.php b/src/Lexers/StatementLexer.php
index 627bfb6..6cf7c7b 100644
--- a/src/Lexers/StatementLexer.php
+++ b/src/Lexers/StatementLexer.php
@@ -80,6 +80,7 @@ class StatementLexer implements Lexer
     private function analyzeSend($statement)
     {
         $to = null;
+        $view = null;
 
         $found = preg_match('/\\s+to:(\\S+)/', $statement, $matches);
         if ($found) {
@@ -87,6 +88,12 @@ class StatementLexer implements Lexer
             $statement = str_replace($matches[0], '', $statement);
         }
 
+        $found = preg_match('/\\s+view:(\\S+)/', $statement, $matches);
+        if ($found) {
+            $view = $matches[1];
+            $statement = str_replace($matches[0], '', $statement);
+        }
+
         [$object, $with] = $this->extractTokens($statement, 2);
 
         $data = [];
@@ -99,7 +106,7 @@ class StatementLexer implements Lexer
             $type = SendStatement::TYPE_NOTIFICATION_WITH_FACADE;
         }
 
-        return new SendStatement($object, $to, $data, $type);
+        return new SendStatement($object, $to, $data, $type, $view);
     }
 
     private function analyzeNotify($statement)
diff --git a/src/Models/Statements/SendStatement.php b/src/Models/Statements/SendStatement.php
index 73716b0..7371f0c 100644
--- a/src/Models/Statements/SendStatement.php
+++ b/src/Models/Statements/SendStatement.php
@@ -2,6 +2,8 @@
 
 namespace Blueprint\Models\Statements;
 
+use Illuminate\Support\Str;
+
 class SendStatement
 {
     const TYPE_MAIL = 'mail';
@@ -30,12 +32,18 @@ class SendStatement
      */
     private $type;
 
-    public function __construct(string $mail, string $to = null, array $data, string $type)
+    /**
+     * @var string
+     */
+    private $view;
+
+    public function __construct(string $mail, ?string $to, array $data, string $type, string $view = null)
     {
         $this->mail = $mail;
         $this->data = $data;
         $this->to = $to;
         $this->type = $type;
+        $this->view = $view ?? 'emails.' . Str::kebab($this->mail);
     }
 
     public function mail()
@@ -79,6 +87,11 @@ class SendStatement
         return $this->type() === SendStatement::TYPE_NOTIFICATION_WITH_FACADE || $this->type() === SendStatement::TYPE_NOTIFICATION_WITH_MODEL;
     }
 
+    public function view()
+    {
+        return $this->view;
+    }
+
     private function mailOutput()
     {
         $code = 'Mail::';
diff --git a/stubs/mail.stub b/stubs/mail.stub
index 23f7b0a..908f313 100644
--- a/stubs/mail.stub
+++ b/stubs/mail.stub
@@ -20,6 +20,6 @@ class {{ class }} extends Mailable
      */
     public function build()
     {
-        return $this->view('view.name');
+        return $this->view('{{ view }}');
     }
 }
diff --git a/stubs/mail.view.stub b/stubs/mail.view.stub
new file mode 100644
index 0000000..47b7343
--- /dev/null
+++ b/stubs/mail.view.stub
@@ -0,0 +1,1 @@
+{{-- Template for {{ class }} --}}


Test patch:
diff --git a/tests/Feature/Generators/Statements/MailGeneratorTest.php b/tests/Feature/Generators/Statements/MailGeneratorTest.php
index d843f00..218b21e 100644
--- a/tests/Feature/Generators/Statements/MailGeneratorTest.php
+++ b/tests/Feature/Generators/Statements/MailGeneratorTest.php
@@ -39,6 +39,9 @@ class MailGeneratorTest extends TestCase
         $this->filesystem->expects('stub')
             ->with('mail.stub')
             ->andReturn($this->stub('mail.stub'));
+        $this->filesystem->expects('stub')
+            ->with('mail.view.stub')
+            ->andReturn($this->stub('mail.view.stub'));
 
         $this->filesystem->shouldNotHaveReceived('put');
 
@@ -53,6 +56,9 @@ class MailGeneratorTest extends TestCase
         $this->filesystem->expects('stub')
             ->with('mail.stub')
             ->andReturn($this->stub('mail.stub'));
+        $this->filesystem->expects('stub')
+            ->with('mail.view.stub')
+            ->andReturn($this->stub('mail.view.stub'));
 
         $this->filesystem->shouldNotHaveReceived('put');
 
@@ -70,13 +76,20 @@ class MailGeneratorTest extends TestCase
         $this->filesystem->expects('stub')
             ->with('mail.stub')
             ->andReturn($this->stub('mail.stub'));
+        $this->filesystem->expects('stub')
+            ->with('mail.view.stub')
+            ->andReturn($this->stub('mail.view.stub'));
         $this->filesystem->shouldReceive('stub')
             ->with('constructor.stub')
             ->andReturn($this->stub('constructor.stub'));
-        $this->filesystem->shouldReceive('exists')
+        $this->filesystem->expects('exists')
             ->twice()
             ->with('app/Mail')
             ->andReturns(false, true);
+        $this->filesystem->expects('exists')
+            ->twice()
+            ->with('resources/views/emails')
+            ->andReturns(false, true);
         $this->filesystem->expects('exists')
             ->with('app/Mail/ReviewPost.php')
             ->andReturnFalse();
@@ -84,16 +97,36 @@ class MailGeneratorTest extends TestCase
             ->with('app/Mail', 0755, true);
         $this->filesystem->expects('put')
             ->with('app/Mail/ReviewPost.php', $this->fixture('mailables/review-post.php'));
+        $this->filesystem->expects('exists')
+            ->with('resources/views/emails/review-post.blade.php')
+            ->andReturnFalse();
+        $this->filesystem->expects('makeDirectory')
+            ->with('resources/views/emails', 0755, true);
+        $this->filesystem->expects('put')
+            ->with('resources/views/emails/review-post.blade.php', $this->fixture('mailables/review-post-view.blade.php'));
+
         $this->filesystem->expects('exists')
             ->with('app/Mail/PublishedPost.php')
             ->andReturnFalse();
         $this->filesystem->expects('put')
             ->with('app/Mail/PublishedPost.php', $this->fixture('mailables/published-post.php'));
+        $this->filesystem->expects('exists')
+            ->with('resources/views/emails/published-post.blade.php')
+            ->andReturnFalse();
+        $this->filesystem->expects('put')
+            ->with('resources/views/emails/published-post.blade.php', $this->fixture('mailables/published-post-view.blade.php'));
 
         $tokens = $this->blueprint->parse($this->fixture('drafts/send-statements.yaml'));
         $tree = $this->blueprint->analyze($tokens);
 
-        $this->assertEquals(['created' => ['app/Mail/ReviewPost.php', 'app/Mail/PublishedPost.php']], $this->subject->output($tree));
+        $this->assertEquals([
+            'created' => [
+                'app/Mail/ReviewPost.php',
+                'resources/views/emails/review-post.blade.php',
+                'app/Mail/PublishedPost.php',
+                'resources/views/emails/published-post.blade.php',
+            ],
+        ], $this->subject->output($tree));
     }
 
     /**
@@ -104,6 +137,9 @@ class MailGeneratorTest extends TestCase
         $this->filesystem->expects('stub')
             ->with('mail.stub')
             ->andReturn($this->stub('mail.stub'));
+        $this->filesystem->expects('stub')
+            ->with('mail.view.stub')
+            ->andReturn($this->stub('mail.view.stub'));
         $this->filesystem->expects('exists')
             ->with('app/Mail/ReviewPost.php')
             ->andReturnTrue();
@@ -128,6 +164,9 @@ class MailGeneratorTest extends TestCase
         $this->filesystem->expects('stub')
             ->with('mail.stub')
             ->andReturn($this->stub('mail.stub'));
+        $this->filesystem->expects('stub')
+            ->with('mail.view.stub')
+            ->andReturn($this->stub('mail.view.stub'));
         $this->filesystem->expects('stub')
             ->with('constructor.stub')
             ->andReturn($this->stub('constructor.stub'));
@@ -141,11 +180,23 @@ class MailGeneratorTest extends TestCase
             ->with('src/path/Mail', 0755, true);
         $this->filesystem->expects('put')
             ->with('src/path/Mail/ReviewPost.php', $this->fixture('mailables/mail-configured.php'));
+        $this->filesystem->expects('exists')
+            ->with('resources/views/emails/review-post.blade.php')
+            ->andReturnFalse();
+        $this->filesystem->expects('makeDirectory')
+            ->with('resources/views/emails', 0755, true);
+        $this->filesystem->expects('put')
+            ->with('resources/views/emails/review-post.blade.php', $this->fixture('mailables/review-post-view.blade.php'));
 
         $tokens = $this->blueprint->parse($this->fixture('drafts/readme-example.yaml'));
         $tree = $this->blueprint->analyze($tokens);
 
-        $this->assertEquals(['created' => ['src/path/Mail/ReviewPost.php']], $this->subject->output($tree));
+        $this->assertEquals([
+            'created' => [
+                'src/path/Mail/ReviewPost.php',
+                'resources/views/emails/review-post.blade.php',
+            ],
+        ], $this->subject->output($tree));
     }
 
     /**
@@ -160,6 +211,9 @@ class MailGeneratorTest extends TestCase
         $this->filesystem->expects('stub')
             ->with('mail.stub')
             ->andReturn($this->stub('mail.stub'));
+        $this->filesystem->expects('stub')
+            ->with('mail.view.stub')
+            ->andReturn($this->stub('mail.view.stub'));
         $this->filesystem->expects('stub')
             ->with('constructor.stub')
             ->andReturn($this->stub('constructor.stub'));
@@ -173,10 +227,113 @@ class MailGeneratorTest extends TestCase
             ->with('src/path/Mail', 0755, true);
         $this->filesystem->expects('put')
             ->with('src/path/Mail/ReviewPost.php', $this->fixture('mailables/return-type-declarations.php'));
+        $this->filesystem->expects('exists')
+            ->with('resources/views/emails/review-post.blade.php')
+            ->andReturnFalse();
+        $this->filesystem->expects('makeDirectory')
+            ->with('resources/views/emails', 0755, true);
+        $this->filesystem->expects('put')
+            ->with('resources/views/emails/review-post.blade.php', $this->fixture('mailables/review-post-view.blade.php'));
 
         $tokens = $this->blueprint->parse($this->fixture('drafts/readme-example.yaml'));
         $tree = $this->blueprint->analyze($tokens);
 
-        $this->assertEquals(['created' => ['src/path/Mail/ReviewPost.php']], $this->subject->output($tree));
+        $this->assertEquals([
+            'created' => [
+                'src/path/Mail/ReviewPost.php',
+                'resources/views/emails/review-post.blade.php',
+            ],
+        ], $this->subject->output($tree));
+    }
+
+    /**
+     * @test
+     */
+    public function output_writes_mails_but_not_existing_templates()
+    {
+        $this->filesystem->expects('stub')
+            ->with('mail.stub')
+            ->andReturn($this->stub('mail.stub'));
+        $this->filesystem->expects('stub')
+            ->with('mail.view.stub')
+            ->andReturn($this->stub('mail.view.stub'));
+        $this->filesystem->shouldReceive('stub')
+            ->with('constructor.stub')
+            ->andReturn($this->stub('constructor.stub'));
+        $this->filesystem->expects('exists')
+            ->twice()
+            ->with('app/Mail')
+            ->andReturns(false);
+        $this->filesystem->expects('exists')
+            ->with('app/Mail/ReviewPost.php')
+            ->andReturnFalse();
+        $this->filesystem->expects('put')
+            ->with('app/Mail/ReviewPost.php', $this->fixture('mailables/review-post.php'));
+        $this->filesystem->expects('exists')
+            ->with('resources/views/emails/review-post.blade.php')
+            ->andReturnTrue();
+
+        $this->filesystem->expects('exists')
+            ->with('app/Mail/PublishedPost.php')
+            ->andReturnFalse();
+        $this->filesystem->expects('put')
+            ->with('app/Mail/PublishedPost.php', $this->fixture('mailables/published-post.php'));
+        $this->filesystem->expects('exists')
+            ->with('resources/views/emails/published-post.blade.php')
+            ->andReturnTrue();
+
+        $tokens = $this->blueprint->parse($this->fixture('drafts/send-statements.yaml'));
+        $tree = $this->blueprint->analyze($tokens);
+
+        $this->assertEquals([
+            'created' => [
+                'app/Mail/ReviewPost.php',
+                'app/Mail/PublishedPost.php',
+            ],
+        ], $this->subject->output($tree));
+    }
+
+    /**
+     * @test
+     */
+    public function output_writes_mail_with_custom_template()
+    {
+        $this->filesystem->expects('stub')
+            ->with('mail.stub')
+            ->andReturn($this->stub('mail.stub'));
+        $this->filesystem->expects('stub')
+            ->with('mail.view.stub')
+            ->andReturn($this->stub('mail.view.stub'));
+        $this->filesystem->shouldReceive('stub')
+            ->with('constructor.stub')
+            ->andReturn($this->stub('constructor.stub'));
+        $this->filesystem->expects('exists')
+            ->with('app/Mail')
+            ->andReturns(true);
+        $this->filesystem->expects('exists')
+            ->with('resources/views/emails/admin')
+            ->andReturns(false);
+        $this->filesystem->expects('exists')
+            ->with('app/Mail/AddedAdmin.php')
+            ->andReturnFalse();
+        $this->filesystem->expects('put')
+            ->with('app/Mail/AddedAdmin.php', $this->fixture('mailables/added-admin.php'));
+        $this->filesystem->expects('exists')
+            ->with('resources/views/emails/admin/added.blade.php')
+            ->andReturnFalse();
+        $this->filesystem->expects('makeDirectory')
+            ->with('resources/views/emails/admin', 0755, true);
+        $this->filesystem->expects('put')
+            ->with('resources/views/emails/admin/added.blade.php', $this->fixture('mailables/added-admin-view.blade.php'));
+
+        $tokens = $this->blueprint->parse($this->fixture('drafts/send-statement-with-view.yaml'));
+        $tree = $this->blueprint->analyze($tokens);
+
+        $this->assertEquals([
+            'created' => [
+                'app/Mail/AddedAdmin.php',
+                'resources/views/emails/admin/added.blade.php',
+            ],
+        ], $this->subject->output($tree));
     }
 }
diff --git a/tests/Feature/Lexers/StatementLexerTest.php b/tests/Feature/Lexers/StatementLexerTest.php
index 093c3a9..6a8ae11 100644
--- a/tests/Feature/Lexers/StatementLexerTest.php
+++ b/tests/Feature/Lexers/StatementLexerTest.php
@@ -166,6 +166,7 @@ class StatementLexerTest extends TestCase
         $this->assertEquals('ReviewPost', $actual[0]->mail());
         $this->assertNull($actual[0]->to());
         $this->assertSame([], $actual[0]->data());
+        $this->assertEquals('emails.review-post', $actual[0]->view());
         $this->assertEquals(SendStatement::TYPE_MAIL, $actual[0]->type());
     }
 
@@ -186,6 +187,7 @@ class StatementLexerTest extends TestCase
         $this->assertEquals('ReviewPost', $actual[0]->mail());
         $this->assertEquals('post.author', $actual[0]->to());
         $this->assertSame([], $actual[0]->data());
+        $this->assertEquals('emails.review-post', $actual[0]->view());
         $this->assertEquals(SendStatement::TYPE_MAIL, $actual[0]->type());
     }
 
@@ -206,6 +208,7 @@ class StatementLexerTest extends TestCase
         $this->assertEquals('ReviewPost', $actual[0]->mail());
         $this->assertNull($actual[0]->to());
         $this->assertEquals(['foo', 'bar', 'baz'], $actual[0]->data());
+        $this->assertEquals('emails.review-post', $actual[0]->view());
         $this->assertEquals(SendStatement::TYPE_MAIL, $actual[0]->type());
     }
 
@@ -226,6 +229,28 @@ class StatementLexerTest extends TestCase
         $this->assertEquals('ReviewPost', $actual[0]->mail());
         $this->assertEquals('post.author', $actual[0]->to());
         $this->assertEquals(['foo', 'bar', 'baz'], $actual[0]->data());
+        $this->assertEquals('emails.review-post', $actual[0]->view());
+        $this->assertEquals(SendStatement::TYPE_MAIL, $actual[0]->type());
+    }
+
+    /**
+     * @test
+     */
+    public function it_returns_a_send_statement_to_with_and_view()
+    {
+        $tokens = [
+            'send' => 'ReviewPost to:post.author with:foo, bar, baz view:email.review-post',
+        ];
+
+        $actual = $this->subject->analyze($tokens);
+
+        $this->assertCount(1, $actual);
+        $this->assertInstanceOf(SendStatement::class, $actual[0]);
+
+        $this->assertEquals('ReviewPost', $actual[0]->mail());
+        $this->assertEquals('post.author', $actual[0]->to());
+        $this->assertEquals(['foo', 'bar', 'baz'], $actual[0]->data());
+        $this->assertEquals('email.review-post', $actual[0]->view());
         $this->assertEquals(SendStatement::TYPE_MAIL, $actual[0]->type());
     }
 
diff --git a/tests/fixtures/drafts/send-statement-with-view.yaml b/tests/fixtures/drafts/send-statement-with-view.yaml
new file mode 100644
index 0000000..77b162f
--- /dev/null
+++ b/tests/fixtures/drafts/send-statement-with-view.yaml
@@ -0,0 +1,5 @@
+controllers:
+  User:
+    store:
+      send: AddedAdmin to:user.email with:user view:emails.admin.added
+      redirect: user.show with:user.id
diff --git a/tests/fixtures/mailables/added-admin-view.blade.php b/tests/fixtures/mailables/added-admin-view.blade.php
new file mode 100644
index 0000000..f5b8273
--- /dev/null
+++ b/tests/fixtures/mailables/added-admin-view.blade.php
@@ -0,0 +1,1 @@
+{{-- Template for AddedAdmin --}}
diff --git a/tests/fixtures/mailables/added-admin.php b/tests/fixtures/mailables/added-admin.php
new file mode 100644
index 0000000..4198f41
--- /dev/null
+++ b/tests/fixtures/mailables/added-admin.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace App\Mail;
+
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Mail\Mailable;
+use Illuminate\Queue\SerializesModels;
+
+class AddedAdmin extends Mailable
+{
+    use Queueable, SerializesModels;
+
+    public $user;
+
+    /**
+     * Create a new message instance.
+     *
+     * @return void
+     */
+    public function __construct($user)
+    {
+        $this->user = $user;
+    }
+
+    /**
+     * Build the message.
+     *
+     * @return $this
+     */
+    public function build()
+    {
+        return $this->view('emails.admin.added');
+    }
+}
diff --git a/tests/fixtures/mailables/mail-configured.php b/tests/fixtures/mailables/mail-configured.php
index d81bd31..7e19977 100644
--- a/tests/fixtures/mailables/mail-configured.php
+++ b/tests/fixtures/mailables/mail-configured.php
@@ -30,6 +30,6 @@ class ReviewPost extends Mailable
      */
     public function build()
     {
-        return $this->view('view.name');
+        return $this->view('emails.review-post');
     }
 }
diff --git a/tests/fixtures/mailables/published-post-view.blade.php b/tests/fixtures/mailables/published-post-view.blade.php
new file mode 100644
index 0000000..b484225
--- /dev/null
+++ b/tests/fixtures/mailables/published-post-view.blade.php
@@ -0,0 +1,1 @@
+{{-- Template for PublishedPost --}}
diff --git a/tests/fixtures/mailables/published-post.php b/tests/fixtures/mailables/published-post.php
index 0d99cd9..bbec792 100644
--- a/tests/fixtures/mailables/published-post.php
+++ b/tests/fixtures/mailables/published-post.php
@@ -28,6 +28,6 @@ class PublishedPost extends Mailable
      */
     public function build()
     {
-        return $this->view('view.name');
+        return $this->view('emails.published-post');
     }
 }
diff --git a/tests/fixtures/mailables/return-type-declarations.php b/tests/fixtures/mailables/return-type-declarations.php
index 4bd172b..ec39688 100644
--- a/tests/fixtures/mailables/return-type-declarations.php
+++ b/tests/fixtures/mailables/return-type-declarations.php
@@ -30,6 +30,6 @@ class ReviewPost extends Mailable
      */
     public function build(): ReviewPost
     {
-        return $this->view('view.name');
+        return $this->view('emails.review-post');
     }
 }
diff --git a/tests/fixtures/mailables/review-post-view.blade.php b/tests/fixtures/mailables/review-post-view.blade.php
new file mode 100644
index 0000000..629d455
--- /dev/null
+++ b/tests/fixtures/mailables/review-post-view.blade.php
@@ -0,0 +1,1 @@
+{{-- Template for ReviewPost --}}
diff --git a/tests/fixtures/mailables/review-post.php b/tests/fixtures/mailables/review-post.php
index 9e783ab..6e03cdd 100644
--- a/tests/fixtures/mailables/review-post.php
+++ b/tests/fixtures/mailables/review-post.php
@@ -30,6 +30,6 @@ class ReviewPost extends Mailable
      */
     public function build()
     {
-        return $this->view('view.name');
+        return $this->view('emails.review-post');
     }
 }