<?php

namespace App\Services\Property;

use App\Enums\PropertyType;
use App\Models\Property;

class PropertyFactory
{
    public static function create($type)
    {

        switch ($type) {
            case PropertyType::HOUSE->name:
                return new HouseService();
            case PropertyType::DEPARTAMENT->name:
                return  new DepartmentService();
            case PropertyType::LAND->name:
                return new LandService();
            case PropertyType::OFFICE->name:
                return new OfficeService();
            case PropertyType::PARK->name:
                return new ParkService();
            default:
            return ;
        }
    }

    public static function getAllProperties()
    {
        return Property::all();
    }

    public static function assingBenefits($property, $benefits)
    {
        $property->benefits()->attach($benefits);
    }

    public static function assingFeatures($property, $features)
    {
        $property->features()->attach($features);
    }

    public static function editarBenefits($property, $benefits)
    {
        $property->benefits()->detach();
        $property->benefits()->attach($benefits);
        return $property;
    }

    public static function editarFeatures($property, $features)
    {
        $property->features()->detach();
        $property->features()->attach($features);
        return $property;
    }
}
