<?php

namespace App\Http\Controllers;

// use App\Http\Controllers\Controller;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use Illuminate\Http\Response as res;
use App\MasterEvent;
use App\EventParticipant;
use App\Users;
use Cookie;

class HomeController extends Controller

{

  public function __construct()

   {

     //  $this->middleware('auth:api');

   }

   /**

    * Display a listing of the resource.

    *

    * @return \Illuminate\Http\Response

    */

   public function index()
   {

    if (Auth::guest())
            {

                 dd('not login');


            }else{

                 // dd('login');
                 $user = Auth::user();
                $uid = $user->id;
                $event = MasterEvent::where('fk_user',$uid)->get();
                return view('admin.show', compact('event'));


            }

    }   

    public function manageevent()
   {

    if (Auth::guest())
            {

                 dd('not login');


            }else{

                 // dd('login');
                 $user = Auth::user();
                $uid = $user->id;
                $event = MasterEvent::where('fk_user',$uid)->get();
                return view('admin.manage', compact('event'));


            }

    }   

    public function manageguest()
    {

    if (Auth::guest())
            {

                 dd('not login');


            }else{

                 // dd('login');
                $user = Auth::user();
                $uid = $user->id;
                $event = MasterEvent::where('fk_user',$uid)->get();

                return view('admin.guest', compact('event'));


            }

    }   

    public function attendance($id)
    {

    if (Auth::guest())
            {

                 dd('not login');


            }else{

                 // dd('login');
                $user = Auth::user();
                $uid = $user->id;
                $event = MasterEvent::where('id',$id)->first();
                // dd($event);

                return view('admin.scan', compact('event'));

               
            }

    } 
    
    public function editevent($id)
    {

    if (Auth::guest())
            {

                 dd('not login');


            }else{

                 // dd('login');
                $user = Auth::user();
                $uid = $user->id;
                $event = MasterEvent::where('id',$id)->get();
                // dd($event);

                return view('admin.detail', compact('event'));

                // return view('admin.guest', compact('event'));

                //  <div class="col-lg-4 col-md-6 col-sm-6">
                //     <div class="cards cards-stats">
                //         <div class="cards-header" data-background-color="orange">
                //             <i class="fa fa-percent"></i>
                //         </div>
                //         <div class="cards-content">
                //             <p class="category">Kempen Aktif</p>
                //             <h3 class="title">{{$camcount}}</h3>
                //         </div>
                //         <div class="cards-footer">
                //             <div class="stats">
                //                 <i class="material-icons text-danger">donut_small</i>
                //                 <a href="campaign">Lihat Tetapan Kempen</a>
                //             </div>
                //         </div>
                //     </div>
                // </div>


            }

    }   
} 

?>