<?php

namespace App\Livewire\Admin;

use App\Models\User;
use Livewire\Component;

class UserDetail extends Component
{
    public $user;
    public $company;
    public $products;
    public $jobs;
    public $forums;

    public function mount($id){
        $this->user = User::with(
            'company',
            'company.category',
            'company.products.category',
            'company.products.productImages',
            'company.jobs',
            'company.forums',
        )->find($id);

        if($this->user != null && $this->user->company != null){
            $this->company = $this->user->company;
            $this->products = $this->user->company->products;
            $this->jobs = $this->user->company->jobs;
            $this->forums = $this->user->company->forums;
        }
    }

    public function render()
    {
        return view('livewire.admin.user-detail');
    }
}
