Skip to content

Commit aae971c

Browse files
authored
Merge pull request #279 from bvipul/develop
Mailables and New Flash function
2 parents f685c40 + 04e8d0d commit aae971c

File tree

21 files changed

+2346
-2155
lines changed

21 files changed

+2346
-2155
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
APP_NAME="Laravel Admin Panel"
2+
APP_SHORT_NAME="LAP"
23
APP_ENV=local
34
APP_KEY=base64:O+TrollIDwasHEREtMG9kBc+/Q32exQLusNVhnq558w=
45
APP_DEBUG=true

app/Exceptions/GeneralException.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,29 @@
99
*/
1010
class GeneralException extends Exception
1111
{
12+
/**
13+
* message.
14+
*
15+
* @var string
16+
*/
17+
public $message;
18+
19+
/**
20+
* dontHide.
21+
*
22+
* @var bool
23+
*/
24+
public $dontHide;
25+
26+
/**
27+
* Constructor function.
28+
*
29+
* @param string $message
30+
* @param bool $dontHide
31+
*/
32+
public function __construct($message, $dontHide = false)
33+
{
34+
$this->message = $message;
35+
$this->dontHide = $dontHide;
36+
}
1237
}

app/Exceptions/Handler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public function report(Exception $exception)
5353
*/
5454
public function render($request, Exception $exception)
5555
{
56-
//dd($exception);
5756
if (strpos($request->url(), '/api/') !== false) {
5857
\Log::debug('API Request Exception - '.$request->url().' - '.$exception->getMessage().(!empty($request->all()) ? ' - '.json_encode($request->except(['password'])) : ''));
5958

@@ -112,6 +111,8 @@ public function render($request, Exception $exception)
112111
* All instances of GeneralException redirect back with a flash message to show a bootstrap alert-error
113112
*/
114113
if ($exception instanceof GeneralException) {
114+
session()->flash('dontHide', $exception->dontHide);
115+
115116
return redirect()->back()->withInput()->withFlashDanger($exception->getMessage());
116117
}
117118

app/Http/Controllers/Api/V1/PagesController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function index(Request $request)
3131
{
3232
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
3333
$orderBy = $request->get('orderBy') ? $request->get('orderBy') : 'ASC';
34-
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : 'created_at';
34+
$sortBy = $request->get('sortBy') ? $request->get('sortBy') : config('module.pages.table', 'pages').'created_at';
3535

3636
return PagesResource::collection(
3737
$this->repository->getForDataTable()->orderBy($sortBy, $orderBy)->paginate($limit)

app/Http/Controllers/Frontend/Auth/LoginController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class LoginController extends Controller
2121
use AuthenticatesUsers;
2222

2323
/**
24-
* @var CMSPagesRepository
24+
* @var \App\Http\Utilities\PushNotification
2525
*/
2626
protected $notification;
2727

@@ -74,7 +74,7 @@ protected function authenticated(Request $request, $user)
7474
if (!$user->isConfirmed()) {
7575
access()->logout();
7676

77-
throw new GeneralException(trans('exceptions.frontend.auth.confirmation.resend', ['user_id' => $user->id]));
77+
throw new GeneralException(trans('exceptions.frontend.auth.confirmation.resend', ['user_id' => $user->id]), true);
7878
} elseif (!$user->isActive()) {
7979
access()->logout();
8080

app/Http/Controllers/Frontend/Auth/ResetPasswordController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,12 @@ protected function validationErrorMessages()
9595
/**
9696
* Get the response for a successful password reset.
9797
*
98-
* @param string $response
98+
* @param \Illuminate\Http\Request $request
99+
* @param string $response
99100
*
100101
* @return \Illuminate\Http\RedirectResponse
101102
*/
102-
protected function sendResetResponse($response)
103+
protected function sendResetResponse($request, $response)
103104
{
104105
return redirect()->route(homeRoute())->withFlashSuccess(trans($response));
105106
}

app/Listeners/Frontend/Auth/UserEventListener.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,6 @@ public function onRegistered($event)
3434
\Log::info('User Registered: '.$event->user->full_name);
3535
}
3636

37-
/**
38-
* @param $event
39-
*/
40-
/*public function onRegistered($event)
41-
{
42-
\Log::info('User Registered: '.$event->user->first_name);
43-
44-
// Send email to the user
45-
$options = [
46-
'data' => $event->user,
47-
'email_template_type' => 1,
48-
];
49-
createNotification('', 1, 2, $options);
50-
}*/
51-
5237
/**
5338
* @param $event
5439
*/

app/Models/Access/User/Traits/Attribute/UserAttribute.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,23 +147,22 @@ public function getStatusButtonAttribute($class)
147147
switch ($this->status) {
148148
case 0:
149149
if (access()->allow('activate-user')) {
150-
$name = $class == '' ? 'Active' : '';
150+
$name = $class == '' ? 'Activate' : '';
151151

152152
return '<a class="'.$class.'" href="'.route('admin.access.user.mark', [$this, 1]).'"><i class="fa fa-check-square" data-toggle="tooltip" data-placement="top" title="'.trans('buttons.backend.access.users.activate').'"></i>'.$name.'</a>';
153153
}
154-
// No break
154+
break;
155155

156156
case 1:
157157
if (access()->allow('deactivate-user')) {
158-
$name = ($class == '') ? 'Deactive' : '';
158+
$name = ($class == '') ? 'Deactivate' : '';
159159

160160
return '<a class="'.$class.'" href="'.route('admin.access.user.mark', [$this, 0]).'"><i class="fa fa-square" data-toggle="tooltip" data-placement="top" title="'.trans('buttons.backend.access.users.deactivate').'"></i>'.$name.'</a>';
161161
}
162-
// No break
162+
break;
163163

164164
default:
165165
return '';
166-
// No break
167166
}
168167
}
169168

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace App\Notifications\Frontend\Auth;
4+
5+
use Illuminate\Bus\Queueable;
6+
use Illuminate\Notifications\Messages\MailMessage;
7+
use Illuminate\Notifications\Notification;
8+
9+
/**
10+
* Class UserChangedPassword.
11+
*/
12+
class UserChangedPassword extends Notification
13+
{
14+
use Queueable;
15+
16+
/**
17+
* @var
18+
*/
19+
protected $password;
20+
21+
/**
22+
* UserChangedPassword constructor.
23+
*
24+
* @param $password
25+
*/
26+
public function __construct($password)
27+
{
28+
$this->password = $password;
29+
}
30+
31+
/**
32+
* Get the notification's delivery channels.
33+
*
34+
* @param mixed $notifiable
35+
*
36+
* @return array
37+
*/
38+
public function via($notifiable)
39+
{
40+
return ['mail'];
41+
}
42+
43+
/**
44+
* Get the mail representation of the notification.
45+
*
46+
* @param \App\Models\Access\User\User $user
47+
*
48+
* @return \Illuminate\Notifications\Messages\MailMessage
49+
*/
50+
public function toMail($user)
51+
{
52+
return (new MailMessage())
53+
->view('emails.changed-password', ['password' => $this->password]);
54+
}
55+
}

app/Notifications/Frontend/Auth/UserNeedsConfirmation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ public function toMail($user)
5252
$confirmation_url = route('frontend.auth.account.confirm', $user->confirmation_code);
5353

5454
return (new MailMessage())
55-
->view('emails.template', ['confirmation_url' => $confirmation_url]);
55+
->view('emails.user-confirmation', ['confirmation_url' => $confirmation_url]);
5656
}
5757
}

0 commit comments

Comments
 (0)