Skip to content

Commit

Permalink
Create Mail Class functionality adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaybokaderanium committed Aug 29, 2023
1 parent a4145fb commit 9c9ec99
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/Helpers/CreateMailableHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Visualbuilder\EmailTemplates\Contracts\CreateMailableInterface;
use Visualbuilder\EmailTemplates\Models\EmailTemplate;
use Illuminate\Support\Facades\File;

class CreateMailableHelper implements CreateMailableInterface
{
Expand All @@ -19,8 +20,11 @@ public function createMailable($record)
// preparing class name
$className = str_replace('-', ' ', $emailTemplate->key);
$className = str_replace(' ', '', ucwords($className));

// prepare directory
$this->prepareDirectory("Mail/Visualbuilder/EmailTemplates");

$filePath = __DIR__ . "/../Mail/$className.php";
$filePath = app_path("Mail/Visualbuilder/EmailTemplates/$className.php");

if(file_exists($filePath)) {
$response->title = "Class already exists";
Expand All @@ -42,4 +46,13 @@ public function createMailable($record)

return $response;
}

public function prepareDirectory($folder)
{
$path = app_path($folder);
if(! File::isDirectory($path)) {
File::makeDirectory($path, 0755, true);
}
return true;
}
}
2 changes: 1 addition & 1 deletion src/Stubs/MailableTemplate.stub
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Visualbuilder\EmailTemplates\Mail;
namespace App\Mail\Visualbuilder\EmailTemplates;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
Expand Down

0 comments on commit 9c9ec99

Please sign in to comment.