<?php

namespace App\Repositories\Property;

use App\Enums\PropertyStatus;
use App\Models\Property;

class PropertyRepository implements PropertyRepositoryInterface
{
    public function all(){
        return Property::all();
    }

    public function allquery(){
        return Property::query();
    }

    public function find($id){
        return Property::find($id);
    }

    public function create(array $data){
        return Property::create($data);
    }

    public function update($id, $data){
        return Property::find($id)->update($data);
    }

    public function delete($id){
        return Property::find($id)?->delete() ?? false;
    }

    public function allPropertiesToProject($project_id){
        return Property::where('project_id',$project_id);
    }
    public function allPropertiesToType($type){
        return Property::where('property_type',$type)
        ->where('status', PropertyStatus::AVAILABLE->name)->get();
    }


}
