Passed
Push — develop ( 7d6347...bbcebd )
by Nikita
06:10
created

GdaemonTasksController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 1
b 0
f 1
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Gameap\Http\Controllers\Admin;
4
5
use Gameap\Exceptions\Repositories\GdaemonTaskRepository\GdaemonTaskRepositoryException;
6
use \Gameap\Http\Controllers\AuthController;
7
use \Gameap\Repositories\GdaemonTaskRepository;
8
use \Gameap\Models\GdaemonTask;
9
10
class GdaemonTasksController extends AuthController 
11
{
12
    /**
13
     * The GdaemonTasksRepository instance.
14
     *
15
     * @var \Gameap\Repositories\GdaemonTaskRepository
16
     */
17
    protected $repository;
18
19
    /**
20
     * Create a new GdaemonTasksController instance.
21
     *
22
     * @param  \Gameap\Repositories\GdaemonTaskRepository $repository
23
     */
24 15
    public function __construct(GdaemonTaskRepository $repository)
25
    {
26 15
        parent::__construct();
27
28 15
        $this->repository = $repository;
29 15
    }
30
31
    /**
32
     * Display a listing of the games.
33
     *
34
     * @return \Illuminate\View\View
35
     */
36 6
    public function index()
37
    {
38 6
        return view('admin.gdaemon_tasks.list',[
39 6
            'gdaemonTasks' => $this->repository->getAll()
40
        ]);
41
    }
42
43
    /**
44
     * Display the specified resource.
45
     *
46
     * @param  \Gameap\Models\GdaemonTask  $gdaemonTask
47
     * @return \Illuminate\View\View
48
     */
49 6
    public function show(GdaemonTask $gdaemonTask)
50
    {
51 6
        return view('admin.gdaemon_tasks.view', compact('gdaemonTask'));
52
    }
53
54
    /**
55
     * @param GdaemonTask $gdaemonTask
56
     */
57 3
    public function cancel(GdaemonTask $gdaemonTask)
58
    {
59
        try {
60 3
            $this->repository->cancel($gdaemonTask);
61 1
        } catch (GdaemonTaskRepositoryException $exception) {
62 1
            return redirect()->route('admin.gdaemon_tasks.show', $gdaemonTask->getKey())
63 1
                ->with('error', __('gdaemon_tasks.canceled_fail_msg', [
64 1
                    'error' => $exception->getMessage(),
65
                ]));
66
        }
67
68 2
        return redirect()->route('admin.gdaemon_tasks.show', $gdaemonTask->getKey())
69 2
            ->with('success', __('gdaemon_tasks.canceled_success_msg'));
70
    }
71
}