<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class modelFloor extends Model
{
  
    public static function selectFloors($code)
    {

        return DB::select("SELECT * FROM `floors` where Code='$code' order by FloorNumber asc");

    }
    public static function selectFloorsName($code,$name)
    {

        return DB::select("SELECT * FROM `floors` where Code='$code' and FloorNumber='$name'");
        
    }
    public static function saveFloor($code,$name,$space, $rooms)
    {
        return DB::insert("INSERT INTO `floors` ( `Code`, `FloorNumber`, `Rooms`, `Space`) VALUES (?, ?,?, ?)", [$code,$name,$rooms, $space] );
    }
    public static function editFloor( $code,$id,$name,$space, $rooms)
    {
      
        return DB::update("UPDATE `floors` SET  `FloorNumber` = ?, `Rooms` = ?, `Space` = ? WHERE `ID` = ? and `Code` = ? ", [ $name,$rooms, $space, $id,$code]);
    }
    public static function deleteFloors( $code,$id)
    {
        return DB::update("DELETE FROM `floors`  WHERE `ID` = ? and `Code` = ? ", [$id,$code]);
    }
}
