Completed
Push — master ( 143ccd...d40d6d )
by Jeremy
06:52
created

AdminController::sitemap()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 10
nc 2
nop 0
dl 0
loc 17
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Controllers\Admin;
4
5
use App\Http\Controllers\Controller;
6
use App\Http\Requests\GenerateSitemapRequest;
7
use Illuminate\Support\Facades\Artisan;
8
use Spatie\Sitemap\Sitemap;
9
10
class AdminController extends Controller
11
{
12
    /**
13
     * Create a new controller instance.
14
     *
15
     * @return void
16
     */
17
    public function __construct()
18
    {
19
        $this->middleware('auth');
20
    }
21
22
    /**
23
     * Show the application dashboard.
24
     *
25
     * @return \Illuminate\Http\Response
26
     */
27
    public function index()
28
    {
29
        return view('admin.pages.home');
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('admin.pages.home') returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
30
    }
31
32
    /**
33
     * Show the application files manager/uploads dashboard.
34
     *
35
     * @return \Illuminate\Http\Response
36
     */
37
    public function uploads()
38
    {
39
        return view('admin.pages.uploads');
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('admin.pages.uploads') returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
40
    }
41
42
    /**
43
     * Show the application sitemap dashboard.
44
     *
45
     * @return \Illuminate\Http\Response
46
     */
47
    public function sitemap()
48
    {
49
        $sitemap    = base_path('public/sitemap.xml');
50
        $modified   = null;
51
        $sitemapxml = [];
52
53
        if (file_exists($sitemap)) {
54
            $sitemapxml = simplexml_load_file($sitemap);
55
            $modified   = date ("F jS, Y H:i:s", filemtime($sitemap));
56
        }
57
58
        $data = [
59
            'sitemap'   => $sitemapxml,
60
            'modified'  => $modified,
61
        ];
62
63
        return view('admin.pages.sitemap', $data);
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('admin.pages.sitemap', $data) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
64
    }
65
66
    /**
67
     * Generate Sitemap from Artisan Command via Request
68
     *
69
     * @param \App\Http\Requests\GenerateSitemapRequest
70
     *
71
     * @return \Illuminate\Http\Response
72
     */
73
    public function generateSitemap(GenerateSitemapRequest $request)
74
    {
75
        Artisan::call('sitemap:generate', ['limit' => $request->limit]);
76
77
        return redirect()->back()->withSuccess(trans('forms.sitemap.messages.success'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->back(...map.messages.success')) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
78
    }
79
80
}
81