Projekt

Obecné

Profil

Stáhnout (1.71 KB) Statistiky
| Větev: | Tag: | Revize:
1
<?php
2

    
3
namespace App\Http\Controllers;
4

    
5
use Illuminate\Contracts\Foundation\Application;
6
use Illuminate\Contracts\View\Factory;
7
use Illuminate\Support\Facades\Auth;
8
use App\Artefact;
9
use App\Http\Controllers\Image;
10
use Illuminate\View\View;
11

    
12
class ChartsController extends Controller
13
{
14
    public function __construct()
15
    {
16
        $this->middleware('auth');
17
    }
18

    
19
    /**
20
     * Display a listing of the resource.
21
     *
22
     * @return Application|Factory|View
23
     */
24
    public function index()
25
    {
26
        if(Auth::check())
27
        {
28
            $artefacts = Artefact::all();
29
            foreach($artefacts as $item)
30
            {
31
                $item['likes'] = Artefact::find($item->id)->users()->count();
32
            }
33
            $artefacts=$artefacts->sortByDesc('likes');
34

    
35
            $data = array(
36
                'title' => 'Charts',
37
                'artefacts' => $artefacts
38
            );
39
            return view('favartefacts.index') -> with($data);
40
        }
41
        else
42
        {
43
            $data = array(
44
                'title' => 'Welcome to the MERLOT page',
45
            );
46
            //return view('index', compact('title'));
47
            return view('pages.index') -> with($data);
48
        }
49
    }
50

    
51
    /**
52
     * Display the specified resource.
53
     *
54
     * @return Application|Factory|View
55
     */
56
    public function show()
57
    {
58
        $artefacts = Artefact::all();
59
        foreach($artefacts as $item)
60
        {
61
            $item['likes'] = Artefact::find($item->id)->users()->count();
62
        }
63
        $artefacts=$artefacts->sortByDesc('likes');
64

    
65
        $data = array(
66
            'title' => 'Charts',
67
            'artefacts' => $artefacts
68
        );
69
        return view('charts.index') -> with($data);
70
    }
71

    
72
}
(3-3/9)