Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 09795926

Přidáno uživatelem Adam Mištera před asi 4 roky(ů)

Issue #7846 @3h
[+] Vytvoření stránky oblíbených metadat
[+] Refraktoring kódu, oprava objektů databáze
[-] Odstranění nepotřebných objektů ArtefactCategory.php a ArtefactUser.php

Zobrazit rozdíly:

app/Http/Controllers/FavoriteArtefactsController.php
21 21
     */
22 22
    public function index()
23 23
    {
24
        if(isset(Auth::user()->id))
24
        if(Auth::check())
25 25
        {
26
            $userId = Auth::user()->id;
27
            $list = ArtefactUser::where('user_id', $userId)->get();
28
            $finalData = array();
29
            foreach($list as $item)
30
            {
31
                array_push($finalData, Artefact::where('id', $item->artefact_id)->get());
32
            }
26
            $artefacts = User::find(Auth::id())->likesArtefacts()->get();
33 27

  
34 28
            $data = array(
35 29
                'title' => 'Favorite artefacts',
36
                'user' => User::find($userId),
37
                'artefacts' => $finalData
30
                'user' => Auth::user(),
31
                'artefacts' => $artefacts
38 32
            );
39 33
            return view('favartefacts.index') -> with($data);
40 34
        }
......
56 50
     */
57 51
    public function show($id)
58 52
    {
59
        $list = ArtefactUser::where('user_id', $id)->get();
60
        $finalData = array();
61
        foreach($list as $item)
53
        $artefacts = [];
54
        if (!is_null(User::find($id)))
62 55
        {
63
            array_push($finalData, Artefact::where('id', $item->artefact_id)->get());
56
            $artefacts = User::find($id)->likesArtefacts()->get();
64 57
        }
65 58

  
66 59
        $data = array(
67 60
            'title' => 'Favorite artefacts',
68 61
            'id' => $id,
69
            'user' => User::find($id),
70
            'userId' => Auth::user()->id,
71
            'artefacts' => $finalData
62
            'user' => Auth::user(),
63
            'userId' => Auth::id(),
64
            'artefacts' => $artefacts
72 65
        );
73 66
        return view('favartefacts.index') -> with($data);
74 67
    }

Také k dispozici: Unified diff