/
PageController.php
75 lines (61 loc) · 1.91 KB
/
PageController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Aren\Page\Worker\PageWorker;
use App\Aren\Page\Repo\PageInterface;
use App\Aren\News\Repo\NewsInterface;
use App\Aren\Prestataire\Repo\PrestataireInterface;
use App\Aren\Troncon\Repo\TronconInterface;
use App\Aren\Icon\Repo\IconInterface;
class PageController extends Controller
{
protected $page;
protected $worker;
protected $helper;
protected $news;
protected $prestataire;
protected $troncon;
protected $icon;
public function __construct(PageWorker $worker, PageInterface $page, NewsInterface $news, PrestataireInterface $prestataire, TronconInterface $troncon, IconInterface $icon)
{
$this->page = $page;
$this->worker = $worker;
$this->news = $news;
$this->prestataire = $prestataire;
$this->troncon = $troncon;
$this->icon = $icon;
$this->helper = new \App\Helper\Helper();
setlocale(LC_ALL, 'fr_FR.UTF-8');
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$page = $this->page->getBySlug($id);
$parent = $page->getAncestorsAndSelf()->toHierarchy();
$template = $page->template;
$data['page'] = $page;
$data['id'] = $id;
$data['parent'] = $parent;
if($id == 'news')
{
$data['news'] = $this->news->getAll();
}
if($id == 'prestataires')
{
$data['prestataires'] = $this->prestataire->getAll(true,true);
}
if($id == 'carte')
{
$data['icons'] = $this->icon->getAll();
$data['cartes'] = $this->troncon->getAll(null);
}
return view('frontend.'.$template)->with($data);
}
}