?
Current File : /home/sanghavirealty/public_html/appazwer/Models/Masterlocation.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Masterlocation extends Model
{
    use HasFactory;

    public $table="masterlocationtbl";

    const CREATED_AT = 'createdate';
    const UPDATED_AT = 'modifydate';


    public static function getLocationName(){

        return  $Combodata = Masterlocation::Where('currentstatus',0)
        ->Where('section',1)
        ->get();

    }


    public static function getVasName(){

      return  $Combodata = Masterlocation::Where('currentstatus',0)
      ->Where('section',3)
      ->get();

  }



    public static function getAreaName($sectionid,$id = 0){

      if(empty($id))
      {

       $Combodata = Masterlocation::Where('currentstatus',0)
      ->Where('section',$sectionid)
      ->get();

      return $Combodata ;
      }

    }


    public static function getAreaNameForCityView($sectionid,$id = 0){

        if(empty($id))
        {

        //  $Combodata = Masterlocation::Where('currentstatus',0)
        // ->Where('section',$sectionid)
        // ->get();

        // return $Combodata ;

        }else{

                if($id != 0 AND is_numeric($id)){

             

                  $areaData = Masterlocation::Where('currentstatus',0)
                  ->Where('section',$sectionid)
                  ->Where('id',$id)
                  ->first();
          
                  return $areaData->title ?? '' ;

                }else {
                  return '-' ;

                }

        }

    }


    public static function getCityTitle($id){



        if(!empty($id)){

        $cityTitle = Masterlocation::Where('currentstatus',0)
        ->Where('section',1)
        ->Where('id',$id)
        ->first();


                  if(!empty($cityTitle->title)){

                    return $cityTitle->title ;

                  }else {

                    return 'Unknown' ;

                  }
    
       

        }else{

            return 'Unknown' ;

        }

    }


    
    // public function getlocationTitle(){
    
    //     return $this->belongsTo(Listing::class, 'location' );
    // }
}