Completed
Push — master ( 8f935b...b02015 )
by ARCANEDEV
11:51
created

RedirectsController::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php namespace Arcanesoft\Seo\Http\Controllers\Admin;
2
3
use Arcanedev\LaravelSeo\Entities\RedirectStatuses;
4
use Arcanedev\LaravelSeo\Models\Redirect;
5
use Arcanesoft\Seo\Http\Requests\Admin\Redirects\CreateRedirectRequest;
6
use Illuminate\Http\Request;
7
use Illuminate\Support\Facades\Log;
8
9
/**
10
 * Class     RedirectsController
11
 *
12
 * @package  Arcanesoft\Seo\Http\Controllers\Admin
13
 * @author   ARCANEDEV <[email protected]>
14
 */
15
class RedirectsController extends Controller
16
{
17
    /* -----------------------------------------------------------------
18
     |  Constructor
19
     | -----------------------------------------------------------------
20
     */
21
    /**
22
     * MetasController constructor.
23
     */
24
    public function __construct()
25
    {
26
        parent::__construct();
27
28
        $this->setCurrentPage('seo-redirects');
29
        $this->addBreadcrumbRoute('Redirections', 'admin::seo.redirects.index');
30
    }
31
32
    /* -----------------------------------------------------------------
33
     |  Main Methods
34
     | -----------------------------------------------------------------
35
     */
36
    public function index()
37
    {
38
        // TODO: Add authorize check
39
40
        $this->setTitle($title = 'List of Redirections');
41
        $this->addBreadcrumb($title);
42
43
        $redirects = Redirect::all();
44
45
        return $this->view('admin.redirects.index', compact('redirects'));
46
    }
47
48
    public function create()
49
    {
50
        // TODO: Add authorize check
51
52
        $this->setTitle($title = 'New Redirection');
53
        $this->addBreadcrumb($title);
54
55
        $statuses = RedirectStatuses::all();
56
57
        return $this->view('admin.redirects.create', compact('statuses'));
58
    }
59
60
    public function store(CreateRedirectRequest $request)
61
    {
62
        // TODO: Add authorize check
63
64
        $redirect = Redirect::createOne(
0 ignored issues
show
Unused Code introduced by
$redirect is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
65
            $request->get('old_url'),
66
            $request->get('new_url'),
67
            $request->get('status')
68
        );
69
70
        $message = "The redirection was created successfully !";
71
        Log::info($message, $post->toArray());
0 ignored issues
show
Bug introduced by
The variable $post does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
72
        $this->notifySuccess($message, 'Redirection created !');
73
74
        return redirect()->route('admin::seo.redirects.index');
75
    }
76
}
77