<?php

namespace App\Http\Controllers;

use App\Models\Item;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class ItemsInfoController extends Controller
{
    public function show(Request $request, Item $item)
    {
        $item->load('category');
        return view('items.info_page', ['item' => $item]);
    }

    public function userItemsAJAX(Request $request)
    {
        $itemListResponse = '';
        foreach (Item::where('user_id',Auth::id())->where('archive','0')->get() as $item) {
            $itemListResponse .= view('templates.info_card', ['item' => $item]);
//            $itemListResponse .= view('templates.item_small_view', ['item' => $item]);
        }
        return $itemListResponse;
    }

}
