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( |
|
|
|
|
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()); |
|
|
|
|
72
|
|
|
$this->notifySuccess($message, 'Redirection created !'); |
73
|
|
|
|
74
|
|
|
return redirect()->route('admin::seo.redirects.index'); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
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.