<?php

namespace App\Http\Controllers\Api\PublicApi;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Listing;


class CompareController extends Controller
{
    public function show(string $slug,string $slug1)
    {
        $listing1 = Listing::query()
        ->published()
        ->where('slug',$slug)
        ->with(['category','consultantProfile','featureValues','media','coverImage'])
        ->firstOrFail();

        $listing2 = Listing::query()
        ->published()
        ->where('slug',$slug1)
        ->with(['category','consultantProfile','featureValues','media','coverImage'])
        ->firstOrFail();

        $listing1_category_id = $listing1->category->id;
        $listing2_category_id = $listing2->category->id;

        abort_unless($listing1_category_id === $listing2_category_id,404,'Farklı kategoriler biribiri ile karşılaştırılamaz');    


        return response()->json([
            'data' => [
                'listing1' => $listing1,
                'listing2' => $listing2,
                
                
            ]
        ]);



    }
}
