1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Larafolio\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use Larafolio\Models\Page; |
6
|
|
|
use Illuminate\Http\Request; |
7
|
|
|
use Larafolio\Models\Project; |
8
|
|
|
use Larafolio\Http\Content\ContentCrud; |
9
|
|
|
|
10
|
|
|
class PortfolioController extends Controller |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Service class for content crud. |
14
|
|
|
* |
15
|
|
|
* @var \Larafolio\Http\Content\ContentCrud |
16
|
|
|
*/ |
17
|
|
|
protected $contentCrud; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Construct. |
21
|
|
|
* |
22
|
|
|
* @param \Larafolio\Http\Content\ContentCrud $contentCrud Service class for crud. |
23
|
|
|
*/ |
24
|
|
|
public function __construct(ContentCrud $contentCrud) |
25
|
|
|
{ |
26
|
|
|
parent::__construct(); |
27
|
|
|
|
28
|
|
|
$this->contentCrud = $contentCrud; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Show the manager dashboard. |
33
|
|
|
* |
34
|
|
|
* @return \Illuminate\Http\Response |
35
|
|
|
*/ |
36
|
|
|
public function index() |
37
|
|
|
{ |
38
|
|
|
$projects = $this->contentCrud->getDashboardProjects(); |
39
|
|
|
|
40
|
|
|
$projectImages = $this->contentCrud->getDashboardProjectImages($projects); |
41
|
|
|
|
42
|
|
|
$projectBlocks = $this->contentCrud->getDashboardProjectBlocks($projects); |
43
|
|
|
|
44
|
|
|
$pages = $this->contentCrud->getDashboardPages(); |
45
|
|
|
|
46
|
|
|
return view('larafolio::dashboard.index', [ |
47
|
|
|
'projects' => $projects, |
48
|
|
|
'projectImages' => $projectImages, |
49
|
|
|
'projectBlocks' => $projectBlocks, |
50
|
|
|
'pages' => $pages, |
51
|
|
|
'icons' => $this->contentCrud->dashboardIcons(), |
52
|
|
|
]); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Update project order in portfolio. |
57
|
|
|
* |
58
|
|
|
* @param \Illuminate\Http\Request $request Request data containing all projects. |
59
|
|
|
* |
60
|
|
|
* @return \Illuminate\Http\Response |
61
|
|
|
*/ |
62
|
|
|
public function update(Request $request) |
63
|
|
|
{ |
64
|
|
|
if ($request->has('projects')) { |
65
|
|
|
$this->user->updateProjectOrder($request->get('projects')); |
66
|
|
|
} elseif ($request->has('pages')) { |
67
|
|
|
$this->user->updatePageOrder($request->get('pages')); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|