<?php

namespace App\Livewire;

use Livewire\Component;
use Illuminate\Support\Facades\DB;
use Livewire\Attributes\Computed;
use Livewire\Attributes\Title;
use Livewire\Attributes\Layout;
use App\Traits\HasBreadcrumb;

#[Title('About Us')]
#[Layout('components.layouts.app')]
class AboutUs extends Component
{
    use HasBreadcrumb;

    public function mount()
    {
        $this->breadcrumbPage = 'about-us';
    }
    
    #[Computed]
    public function company()
    {
        return DB::table('companies')->where('id', 1)->first();
    }

    #[Computed]
    public function vision()
    {
        return \App\Models\Page::where('slug', 'vision')
            ->where('is_published', true)
            ->first();
    }

    #[Computed]
    public function mission()
    {
        return \App\Models\Page::where('slug', 'mission')
            ->where('is_published', true)
            ->first();
    }

    #[Computed]
    public function page()
    {
        return \App\Models\Page::where('id',1)
            ->where('is_published', true)
            ->first();
    }

    #[Computed]
    public function goals()
    {
        return \App\Models\Goal::orderBy('order', 'asc')
            ->get();
    }

    #[Computed]
    public function clients()
    {
        return \App\Models\Client::active()
            ->select(['id', 'name', 'logo'])
            ->get();
    }

    public function render()
    {
        return view('livewire.about-us');
    }
}
