Passed
Push — develop ( d2ded6...15ac65 )
by Nikita
19:39
created

ClientCertificatesController::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Gameap\Http\Controllers\Admin;
4
5
use Gameap\Exceptions\GameapException;
6
use Gameap\Http\Controllers\AuthController;
7
use Gameap\Models\ClientCertificate;
8
use Gameap\Repositories\ClientCertificateRepository;
9
use Gameap\Http\Requests\ClientCertificatesRequest;
10
11
class ClientCertificatesController extends AuthController
12
{
13
    /**
14
     * The ClientCertificateRepository instance.
15
     *
16
     * @var \Gameap\Repositories\ClientCertificateRepository
17
     */
18
    protected $repository;
19
20
    /**
21
     * Create a new ClientCertificatesController instance.
22
     *
23
     * @param  \Gameap\Repositories\ClientCertificateRepository $repository
24
     */
25 27
    public function __construct(ClientCertificateRepository $repository)
26
    {
27 27
        parent::__construct();
28
29 27
        $this->repository = $repository;
30 27
    }
31
32
    /**
33
     * Display a listing of the resource.
34
     *
35
     * @return \Illuminate\View\View
36
     */
37 6
    public function index()
38
    {
39 6
        $clientCertificates = $this->repository->getAll();
40
41 6
        return view('admin.client_certificates.list', compact('clientCertificates'));
42
    }
43
44
    /**
45
     * Show the form for creating a new resource.
46
     *
47
     * @return \Illuminate\View\View
48
     */
49 6
    public function create()
50
    {
51 6
        return view('admin.client_certificates.create');
52
    }
53
54
    /**
55
     * Store a newly created resource in storage.
56
     *
57
     * @param  \Gameap\Http\Requests\ClientCertificatesRequest  $request
58
     * @return \Illuminate\Http\RedirectResponse
59
     */
60 9
    public function store(ClientCertificatesRequest $request)
61
    {
62
        try {
63 9
            $this->repository->store($request);
64
65 3
            return redirect()->route('admin.client_certificates.index')
66 3
                ->with('success', __('client_certificates.create_success_msg'));
67 6
        } catch (GameapException $e) {
68 6
            return redirect()->back()
69 6
                ->withErrors([$e->getMessage()]);
70
        }
71
    }
72
73
    /**
74
     * Display the specified resource.
75
     *
76
     * @param  \Gameap\Models\ClientCertificate  $clientCertificate
77
     * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
78
     */
79 3
    public function show(ClientCertificate $clientCertificate)
80
    {
81 3
        $certificateInfo = $this->repository->certificateInfo($clientCertificate);
82
        
83 3
        return view('admin.client_certificates.view', compact('clientCertificate', 'certificateInfo'));
84
    }
85
    
86
    /**
87
     * Remove the specified resource from storage.
88
     *
89
     * @param  \Gameap\Models\ClientCertificate  $clientCertificate
90
     * @return \Illuminate\Http\RedirectResponse
91
     */
92 3
    public function destroy(ClientCertificate $clientCertificate)
93
    {
94 3
        $this->repository->destroy($clientCertificate);
95
96 3
        return redirect()->route('admin.client_certificates.index')
97 3
            ->with('success',  __('client_certificates.delete_success_msg'));
98
    }
99
}