Projekt

Obecné

Profil

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

    
3
namespace App\Http\Controllers;
4

    
5
use App\ArtefactCategory;
6
use App\Category;
7
use Illuminate\Support\Facades\Auth;
8
use App\User;
9

    
10
class CategoriesController extends Controller
11
{
12
    public function __construct()
13
    {
14
        $this->middleware('auth');
15
    }
16

    
17
    /**
18
     * Display a listing of the resource.
19
     *
20
     * @return \Illuminate\Http\Response
21
     */
22
    public function index()
23
    {
24
        if(isset(Auth::user()->id))
25
        {
26
            $userId = Auth::user()->id;
27

    
28
            $categoryNames = Category::orderBy('id')->get();
29
            $countCategory = count($categoryNames);
30

    
31
            $data = array(
32
                'title' => 'Categories',
33
                'user' => User::find($userId),
34
                'count' => $countCategory,
35
                'categoryNames' => $categoryNames
36
            );
37
            return view('categories.index') -> with($data);
38
        }
39
        else
40
        {
41
            $data = array(
42
                'title' => 'Welcome to the MERLOT page',
43
            );
44
            return view('pages.index') -> with($data);
45
        }
46
    }
47
}
(2-2/10)