SendTestEmailController::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 17
rs 9.9666
cc 2
nc 2
nop 1
1
<?php
2
3
namespace App\Http\Controllers\Admin\Email;
4
5
use Exception;
6
7
use Illuminate\Http\Request;
8
use Illuminate\Support\Facades\Auth;
9
use Illuminate\Support\Facades\Notification;
10
11
use App\Models\AppSettings;
12
use App\Http\Controllers\Controller;
13
use App\Notifications\SendTestEmail;
14
15
class SendTestEmailController extends Controller
16
{
17
    /**
18
     * Send a test email
19
     */
20
    public function __invoke(Request $request)
21
    {
22
        $this->authorize('viewAny', AppSettings::class);
23
24
        try
25
        {
26
            Notification::send(Auth::user(), new SendTestEmail);
27
28
            return [
29
                'success' => true,
30
            ];
31
        }
32
        catch(Exception $e)
33
        {
34
            return [
35
                'success' => false,
36
                'message' => $e->getMessage(),
37
            ];
38
        }
39
    }
40
}
41