Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 609126cb

Přidáno uživatelem Jiří Noháč před asi 4 roky(ů)

Uprava sjednoceni templatu pro "Artefacts"

Uprava a sjednoceni vsech stranek (vyjma charts) na stejny design zobrazeni artefaktu podle 'books.blade'. Mezi upravene stranky patri: artefact, category, categories, favartefacts.

Zobrazit rozdíly:

app/Http/Controllers/FavoriteArtefactsController.php
12 12

  
13 13
class FavoriteArtefactsController extends Controller
14 14
{
15
    const ORDER_COLUMN = 'page';
16

  
15 17
    public function __construct()
16 18
    {
17 19
        $this->middleware('auth');
18 20
    }
19 21

  
22
    /**
23
     * Prepare all necessary data for shown Artefact.
24
     * These are current count of likes, if it set to
25
     * a favorites by a logged user and all metadata
26
     * connected to the artefact.
27
     *
28
     * @param       $artefacts  all artefacts
29
     * @return      mixed       modified artefacts
30
     */
31
    public function prepData($artefacts)
32
    {
33
        foreach($artefacts as $artefact)
34
        {
35
            $artefact['likes'] = Artefact::find($artefact->id)->users()->count();
36
            $artefact['favourite'] = is_null(User::find(Auth::id())->likesArtefacts()->find($artefact->id)) ? false : true;
37
            $metadata = Artefact::find($artefact->id)->metadata()->orderBy(self::ORDER_COLUMN)->get();
38
            foreach ($metadata as $item)
39
            {
40
                $item['favourite'] = is_null(User::find(Auth::id())->likesMetadata()->find($item->id)) ? false : true;
41
            }
42
            $artefact['metadata'] = $metadata;
43
        }
44
        return $artefacts;
45
    }
46

  
20 47
    /**
21 48
     * Display a listing of the resource.
22 49
     *
......
27 54
        if(Auth::check())
28 55
        {
29 56
            $id = Auth::id();
30
            $artefacts = User::find($id)->likesArtefacts()->get();
31
            foreach($artefacts as $item)
32
            {
33
                $item['likes'] = Artefact::find($item->id)->users()->count();
34
            }
35

  
36
            $data = array(
37
                'title' => 'Favorite artefacts',
38
                'user' => $id,
39
                'artefacts' => $artefacts
40
            );
41
            return view('favartefacts.index') -> with($data);
57
            $artefacts = User::find($id)->likesArtefacts()->simplePaginate(1);
58
            $artefacts = $this->prepData($artefacts);
59
            return view('artefact.default', ['artefacts' => $artefacts]);
42 60
        }
43 61
        else
44 62
        {
45
            $data = array(
46
                'title' => 'Welcome to the MERLOT page',
47
            );
48
            //return view('index', compact('title'));
49
            return view('pages.index') -> with($data);
63
            return view('pages.index');
50 64
        }
51 65
    }
52 66

  
......
58 72
     */
59 73
    public function show($id)
60 74
    {
61
        $artefacts = User::find($id)->likesArtefacts()->get();
62
        foreach($artefacts as $item)
63
        {
64
            $item['likes'] = Artefact::find($item->id)->users()->count();
65
        }
66

  
67
        $data = array(
68
            'title' => 'Favorite artefacts',
69
            'id' => $id,
70
            'user' => User::find($id),
71
            'userId' => Auth::id(),
72
            'artefacts' => $artefacts
73
        );
74
        return view('favartefacts.index') -> with($data);
75
        $artefacts = User::find($id)->likesArtefacts()->simplePaginate(1);
76
        $artefacts = $this->prepData($artefacts);
77
        return view('artefact.default', ['artefacts' => $artefacts]);
75 78
    }
76 79

  
77 80
}

Také k dispozici: Unified diff