Skip to content

Commit 6cd5650

Browse files
Merge pull request #108 from shubhwebkul/master
emails added and fixed issues
2 parents fd96ad2 + 5f6c56d commit 6cd5650

File tree

20 files changed

+239
-25
lines changed

20 files changed

+239
-25
lines changed

packages/Webkul/Admin/src/DataGrids/Contact/OrganizationDataGrid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function addColumns()
6161
'head_style' => 'width: 100px',
6262
'label' => trans('admin::app.datagrid.persons_count'),
6363
'type' => 'string',
64-
'searchable' => true,
64+
'searchable' => false,
6565
'closure' => function ($row) {
6666
$personsCount = $this->personRepository
6767
->findWhere(['organization_id' => $row->id])

packages/Webkul/Admin/src/Http/Controllers/Activity/ActivityController.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,6 @@ public function update($id)
9393
}
9494
}
9595

96-
/**
97-
* Send email
98-
*
99-
* @param int $id
100-
* @return \Illuminate\View\View
101-
*/
102-
public function sendEmail($id)
103-
{
104-
dd(request()->all());
105-
$lead = $this->leadRepository->findOrFail($id);
106-
107-
}
108-
10996
/*
11097
* Remove the specified resource from storage.
11198
*

packages/Webkul/Admin/src/Http/Controllers/Contact/PersonController.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
namespace Webkul\Admin\Http\Controllers\Contact;
44

5+
use Illuminate\Support\Facades\Mail;
56
use Illuminate\Support\Facades\Event;
7+
68
use Webkul\Admin\Http\Controllers\Controller;
9+
use Webkul\Admin\Notifications\Person\Create;
710
use Webkul\Attribute\Http\Requests\AttributeForm;
811
use Webkul\Contact\Repositories\PersonRepository;
912

@@ -52,6 +55,12 @@ public function store(AttributeForm $request)
5255

5356
$person = $this->personRepository->create(request()->all());
5457

58+
try {
59+
// Mail::queue(new Create($person));
60+
} catch (\Exception $e) {
61+
report($e);
62+
}
63+
5564
Event::dispatch('contacts.person.create.after', $person);
5665

5766
session()->flash('success', trans('admin::app.contacts.persons.create-success'));

packages/Webkul/Admin/src/Http/Controllers/Lead/LeadController.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
use Carbon\Carbon;
66
use Illuminate\Support\Facades\Event;
77
use Illuminate\Support\Facades\Storage;
8+
use Illuminate\Support\Facades\Mail;
89

10+
use Webkul\Admin\Notifications\Lead\Create;
911
use Webkul\Lead\Repositories\LeadRepository;
1012
use Webkul\Lead\Repositories\FileRepository;
1113
use Webkul\Lead\Repositories\StageRepository;
@@ -84,6 +86,14 @@ public function store(AttributeForm $request)
8486

8587
$lead = $this->leadRepository->create($data);
8688

89+
$user = $this->leadRepository->getUserByLeadId($lead->id);
90+
91+
try {
92+
Mail::queue(new Create($user, $lead->id));
93+
} catch (\Exception $e) {
94+
report($e);
95+
}
96+
8797
Event::dispatch('lead.create.after', $lead);
8898

8999
session()->flash('success', trans('admin::app.leads.create-success'));

packages/Webkul/Admin/src/Http/Controllers/Setting/UserController.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
use Illuminate\Support\Str;
66
use Illuminate\Support\Facades\Hash;
77
use Illuminate\Support\Facades\Event;
8+
use Illuminate\Support\Facades\Mail;
89

910
use Webkul\Admin\Http\Requests\UserForm;
1011
use Webkul\User\Repositories\RoleRepository;
1112
use Webkul\User\Repositories\UserRepository;
13+
use Webkul\Admin\Notifications\User\Create;
1214
use Webkul\Admin\Http\Controllers\Controller;
1315

1416
class UserController extends Controller
@@ -97,6 +99,12 @@ public function store()
9799

98100
$admin->save();
99101

102+
try {
103+
Mail::queue(new Create($admin));
104+
} catch (\Exception $e) {
105+
report($e);
106+
}
107+
100108
Event::dispatch('settings.user.create.after', $admin);
101109

102110
session()->flash('success', trans('admin::app.settings.users.create-success'));
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Webkul\Admin\Notifications\Lead;
4+
5+
use Illuminate\Mail\Mailable;
6+
use Illuminate\Notifications\Messages\MailMessage;
7+
8+
class Create extends Mailable
9+
{
10+
/**
11+
* @param object $user
12+
* @param Number $leadId
13+
* @return void
14+
*/
15+
public function __construct($user, $leadId)
16+
{
17+
$this->user = $user;
18+
$this->leadId = $leadId;
19+
}
20+
21+
/**
22+
* Build the mail representation of the notification.
23+
*/
24+
public function build()
25+
{
26+
return $this
27+
->to($this->user->email)
28+
->subject(trans('admin::app.mail.lead.create-subject'))
29+
->view('admin::emails.leads.create', [
30+
'user_name' => $this->user->name,
31+
'lead_id' => $this->leadId,
32+
]);
33+
}
34+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Webkul\Admin\Notifications\Person;
4+
5+
use Illuminate\Mail\Mailable;
6+
use Illuminate\Notifications\Messages\MailMessage;
7+
8+
class Create extends Mailable
9+
{
10+
/**
11+
* @param object $person
12+
* @return void
13+
*/
14+
public function __construct($person)
15+
{
16+
$this->person = $person;
17+
}
18+
19+
/**
20+
* Build the mail representation of the notification.
21+
*/
22+
public function build()
23+
{
24+
$personEmails = \Arr::pluck($this->person->emails, 'value');
25+
26+
return $this
27+
->to($personEmails)
28+
->subject(trans('admin::app.mail.person.create-subject'))
29+
->view('admin::emails.persons.create', [
30+
'person_name' => $this->person->name,
31+
]);
32+
}
33+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Webkul\Admin\Notifications\User;
4+
5+
use Illuminate\Mail\Mailable;
6+
use Illuminate\Notifications\Messages\MailMessage;
7+
8+
class Create extends Mailable
9+
{
10+
/**
11+
* @param object $user
12+
* @return void
13+
*/
14+
public function __construct($user)
15+
{
16+
$this->user = $user;
17+
}
18+
19+
/**
20+
* Build the mail representation of the notification.
21+
*/
22+
public function build()
23+
{
24+
return $this
25+
->to($this->user->email)
26+
->subject(trans('admin::app.mail.user.create-subject'))
27+
->view('admin::emails.users.create', [
28+
'user_name' => $this->user->name,
29+
]);
30+
}
31+
}

packages/Webkul/Admin/src/Resources/lang/en/app.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,21 @@
276276
'final-summary' => 'If you did not request a password reset, no further action is required',
277277
'thanks' => 'Thanks!'
278278
],
279+
280+
'person' => [
281+
'create-subject' => 'You are added as a customer.',
282+
'create-body' => 'Congratulations! You are added as a person.',
283+
],
284+
285+
'user' => [
286+
'create-subject' => 'You are added as a member.',
287+
'create-body' => 'Congratulations! You are now a member of our team.',
288+
],
289+
290+
'lead' => [
291+
'create-subject' => 'New lead generated',
292+
'create-body' => 'A new <a href=":leadLink">lead</a> has been generated successfully!',
293+
]
279294
],
280295

281296
'activities' => [
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@component('admin::emails.layouts.master')
2+
<div style="text-align: center;">
3+
<a href="{{ config('app.url') }}">
4+
<img src="{{ asset('vendor/webkul/admin/assets/images/logo.svg') }}" alt="{{ config('app.name') }}"/>
5+
</a>
6+
</div>
7+
8+
<div style="padding: 30px;">
9+
<div style="font-size: 20px;color: #242424;line-height: 30px;margin-bottom: 34px;">
10+
<p style="font-size: 16px;color: #5E5E5E;line-height: 24px;">
11+
{{ __('admin::app.mail.forget-password.dear', ['name' => $user_name]) }},
12+
</p>
13+
14+
<p style="font-size: 16px;color: #5E5E5E;line-height: 24px;">
15+
{!! __('admin::app.mail.lead.create-body', ['leadLink' => route('admin.leads.view', ['id' => $lead_id])]) !!}
16+
</p>
17+
</div>
18+
</div>
19+
@endcomponent

0 commit comments

Comments
 (0)