<?php

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
use Inertia\Inertia;

class UserController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param Request $request
     * @return Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param int $id
     * @return Response
     */
    public function show($slug = null)
    {
        $slug = $slug ?? Auth::user()->slug;
        $user = User::with('location', 'socialLinks')->where('slug', $slug)->firstOrFail();
        return Inertia::render('Dashboard/Index', [
            'user' => $user,
        ]);

    }



    /**
     * Show the form for editing the specified resource.
     *
     * @param int $id
     * @return Response
     */
    public function edit($id)
    {
        //
    }

    /**
     *
     *
     * @param Request $request
     * @param int $id
     * @return Response
     */
    public function clearNotifications()
    {
        $user = Auth::user();
        // dd(1);
        $user->clearAllNotifications();
        return back(303);
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param int $id
     * @return Response
     */
    public function destroy($id)
    {
        //
    }
}
