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/ArtefactController.php
4 4

  
5 5
use App\Artefact;
6 6
use App\ArtefactCategory;
7
use App\Category;
7 8
use App\User;
8 9
use Illuminate\Contracts\View\Factory;
9 10
use Illuminate\Http\RedirectResponse;
......
20 21
    }
21 22

  
22 23
    /**
23
     * Returns view of all artefacts.
24
     * Prepare all necessary data for shown Artefact.
25
     * These are current count of likes, if it set to
26
     * a favorites by a logged user and all metadata
27
     * connected to the artefact.
24 28
     *
25
     * @return Factory|View
29
     * @param       $artefacts  all artefacts
30
     * @return      mixed       modified artefacts
26 31
     */
27
    public function default()
32
    public function prepData($artefacts)
28 33
    {
29
        $artefacts = Artefact::simplePaginate(1);
30 34
        foreach($artefacts as $artefact)
31 35
        {
32 36
            $artefact['likes'] = Artefact::find($artefact->id)->users()->count();
......
41 45
            $artefact['metadata'] = $metadata;
42 46
        }
43 47

  
48
        return $artefacts;
49
    }
50

  
51
    /**
52
     * Returns view of all artefacts.
53
     *
54
     * @return Factory|View
55
     */
56
    public function default()
57
    {
58
        $artefacts = Artefact::simplePaginate(1);
59
        $artefacts = $this->prepData($artefacts);
44 60
        return view('artefact.default', ['artefacts' => $artefacts]);
45 61
    }
46 62

  
......
52 68
     */
53 69
    public function showCategory($id)
54 70
    {
55
        $categoryArtefacts = ArtefactCategory::where('category_id', $id)->get();
56
        if(count($categoryArtefacts) > 0)
57
        {
58
            $artefacts = array();
59
            foreach($categoryArtefacts as $ar)
60
            {
61
                array_push($artefacts, Artefact::where('id', $ar->artefact_id)->get());
62
            }
63
            return view('artefact.category', ['artefacts' => $artefacts]);
64
        }
65
        else
66
        {
67
            return view('artefact.category', ['artefacts' => array()]);
68
        }
71
        $artefacts = Category::find($id)->artefacts()->simplePaginate(1);
72
        $artefacts = $this->prepData($artefacts);
73
        return view('artefact.default', ['artefacts' => $artefacts]);
69 74
    }
70 75

  
71 76
    /**
72
     * Returns view of artefacts related to the chosen category
77
     * Returns view of artefacts related to the chosen categories
73 78
     *
74 79
     * @param $id string with categories ids
75 80
     * @return Factory|View
76 81
     */
77 82
    public function showCategories($id)
78 83
    {
84
        //Parsing text for individual ids of categories
79 85
        $textWithIds  = $id;
80 86
        $pieces = explode(",", $textWithIds);
81
        $artefacts = array();
87
        $arrStrToInt = array();
82 88
        for($i = 0;$i < count($pieces); $i++)
83 89
        {
84 90
            if($pieces[$i] == null || !strcmp($pieces[$i], ""))
......
86 92
                continue;
87 93
            }
88 94

  
89
            $categoryArtefacts = ArtefactCategory::where('category_id', $pieces[$i])->get();
90
            if(count($categoryArtefacts) > 0)
91
            {
92
                foreach($categoryArtefacts as $ar)
93
                {
94
                    array_push($artefacts, Artefact::where('id', $ar->artefact_id)->get());
95
                }
96
            }
95
            array_push($arrStrToInt, (int)$pieces[$i]);
97 96
        }
98 97

  
99
        if(count($artefacts) > 0)
98
        //Creating array of all artefacts ids
99
        $arrArtIds = array();
100
        foreach($arrStrToInt as $cat)
100 101
        {
101
            return view('artefact.category', ['artefacts' => $artefacts]);
102
        }
103
        else
104
        {
105
            return view('artefact.category', ['artefacts' => array()]);
102
            $tmpArtefacts = Category::find($cat)->artefacts()->get();
103
            foreach($tmpArtefacts as $art)
104
            {
105
                array_push($arrArtIds, $art->id);
106
            }
106 107
        }
108

  
109
        $artefacts = Artefact::whereIn('id', $arrArtIds)->simplePaginate(1);
110
        $artefacts = $this->prepData($artefacts);
111
        return view('artefact.default', ['artefacts' => $artefacts]);
107 112
    }
108 113

  
109 114
    /**
......
114 119
     */
115 120
    public function view($id)
116 121
    {
117
        $artefact = Artefact::find($id);
118
        $artefact['likes'] = Artefact::find($id)->users()->count();
119
        $artefact['favourite'] = is_null(User::find(Auth::id())->likesArtefacts()->find($id)) ? false : true;
120

  
121
        return view('artefact.view', ['artefact' => $artefact]);
122
        $artefact = Artefact::find($id)->simplePaginate(1);
123
        $artefact = $this->prepData($artefact);
124
        //return view('artefact.view', ['artefact' => $artefact]);
125
        return view('artefact.default', ['artefacts' => $artefact]);
122 126
    }
123 127

  
124 128
    /**
app/Http/Controllers/Auth/RegisterController.php
6 6
use App\Mail\RegisterMail;
7 7
use App\Providers\RouteServiceProvider;
8 8
use App\User;
9
use Illuminate\Routing\UrlGenerator;
9 10
use Illuminate\Foundation\Auth\RegistersUsers;
10 11
use Illuminate\Support\Facades\Hash;
11 12
use Illuminate\Support\Facades\Mail;
......
70 71
        $vowels = array("/", "\\");
71 72
        $stringHModified = str_replace($vowels, "", $stringH);
72 73

  
73
        Mail::to($data['email'])->send(new RegisterMail("http://localhost/verify/". $stringHModified));
74
        //Mail::to($data['email'])->send(new RegisterMail("http://localhost/verify/". $stringHModified));
75
        Mail::to($data['email'])->send(new RegisterMail(url("/verify/") . "/" . $stringHModified));//http://localhost/register/verify/..
74 76

  
75 77
        return User::create([
76 78
            'name' => $data['name'],
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
}
resources/sass/_custom.scss
800 800
    //VERIFY - main text
801 801
    .ver-text{
802 802

  
803
        margin-top: 20pt    ;
803
        margin-top: 50pt;
804 804

  
805 805
        h2{
806 806
            text-align: center;

Také k dispozici: Unified diff