1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* rmarchiv.tk |
5
|
|
|
* (c) 2016-2017 by Marcel 'ryg' Hering |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace App\Http\Controllers; |
9
|
|
|
|
10
|
|
|
use Sitemap; |
11
|
|
|
use App\Models\Game; |
12
|
|
|
use App\Models\News; |
13
|
|
|
use App\Models\User; |
14
|
|
|
use App\Models\Developer; |
15
|
|
|
use App\Models\BoardThread; |
16
|
|
|
|
17
|
|
|
class SitemapController extends Controller |
18
|
|
|
{ |
19
|
|
|
public function index() |
|
|
|
|
20
|
|
|
{ |
21
|
|
|
Sitemap::addSitemap(route('sitemap.users')); |
22
|
|
|
Sitemap::addSitemap(route('sitemap.games')); |
23
|
|
|
Sitemap::addSitemap(route('sitemap.developer')); |
24
|
|
|
Sitemap::addSitemap(route('sitemap.board')); |
25
|
|
|
Sitemap::addSitemap(route('sitemap.news')); |
26
|
|
|
|
27
|
|
|
return Sitemap::index(); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
View Code Duplication |
public function users() |
|
|
|
|
31
|
|
|
{ |
32
|
|
|
$users = User::all(); |
33
|
|
|
|
34
|
|
|
foreach ($users as $user) { |
35
|
|
|
Sitemap::addTag(route('users.show', $user->id), $user->created_at, 'monthly', '0.8'); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
return Sitemap::render(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function games() |
|
|
|
|
42
|
|
|
{ |
43
|
|
|
$games = Game::all(); |
44
|
|
|
|
45
|
|
|
foreach ($games as $game) { |
46
|
|
|
$tag = Sitemap::addTag(url('games', $game->id), $game->created_at, 'monthly', '0.8'); |
47
|
|
|
$tag->addImage(route('screenshot.show', [$game->id, 1]), 'Titlescreen'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
return Sitemap::render(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
View Code Duplication |
public function developer() |
|
|
|
|
54
|
|
|
{ |
55
|
|
|
$dev = Developer::all(); |
56
|
|
|
|
57
|
|
|
foreach ($dev as $d) { |
58
|
|
|
Sitemap::addTag(url('developer', $d->id), $d->created_at, 'monthly', '0.8'); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
return Sitemap::render(); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
View Code Duplication |
public function board() |
|
|
|
|
65
|
|
|
{ |
66
|
|
|
$threads = BoardThread::all(); |
67
|
|
|
|
68
|
|
|
foreach ($threads as $thread) { |
69
|
|
|
Sitemap::addTag(route('board.thread.show', $thread->id), $thread->last_created_at, 'daily', '0.8'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
return Sitemap::render(); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function news() |
|
|
|
|
76
|
|
|
{ |
77
|
|
|
$news = News::all()->where('approved', '=', 1); |
78
|
|
|
|
79
|
|
|
foreach ($news as $new) { |
80
|
|
|
Sitemap::addTag(url('news', $new->id), $new->created_at, 'monthly', '0.8'); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
return Sitemap::render(); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.