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

namespace App\Models;


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




class Cmsblock extends Model
{
    use HasFactory;


    public $table="cmsblocktbl";


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

    
    

    public function getNavigationTitle()
    {
            return $this->belongsTo(Navigation::class, 'categoryid');
    }



 


    public function navSub()
    {

     return $this->hasMany(Cmsblock::class,'parentid','id')->with('navSub') ;
 
     }




    public static function getHeader (){

        $dataviewer = Cmsblock::Where('currentstatus',0)
        ->Where('parentid',0)
        ->Where('categoryid',3)
     
        ->with('navSub.navSub')
        ->get();
   
        // ->orderBy('orderby', 'ASC')
        // ->get();

   
        
     return $dataviewer ;

        //  return view('navigation.headernavigator',['data'=>$dataviewer]);


    }





    public static function getFooterLinks ($type){

        $dataviewer = Cmsblock::Where('currentstatus',0)
    ->Where('categoryid',$type)
        ->orderBy('orderby', 'ASC')
        ->get();
        
     return $dataviewer ;

        //  return view('navigation.headernavigator',['data'=>$dataviewer]);


    }




        public static function getChildPages ($parentId, $limit=12){

        $dataviewer = Cmsblock::Where('currentstatus',0)
        ->Where('parentid',$parentId)
        ->orderBy('orderby', 'ASC')
        ->limit($limit)
        ->get();
        
     return $dataviewer ;

        //  return view('navigation.headernavigator',['data'=>$dataviewer]);


    }





    public static function getImageInsertedInBetweenDescription ($imagePath2,$description,$imagePath3){

        if(!empty($imagePath2)){
        $getimagepath = asset('/storage/contentimages/'.$imagePath2);
        $imagepath = '<img class="second-image" id="secondimage" src="'.$getimagepath.'" >' ;
        $textArray = str_split($description);
        $halfway = ceil(count($textArray) / 2);
        array_splice($textArray, $halfway, 0, $imagepath);
        $textWithImage = implode('', $textArray);

        
        if(!empty($imagePath3)){ 

            $getimagepath = asset('/storage/contentimages/'.$imagePath3);
            $imagepath = '<img class="third-image" id="thirdimage" src="'.$getimagepath.'" >' ;
            $textArray = str_split($textWithImage);
            $halfway = ceil(count($textArray));
           
            array_splice($textArray, $halfway, 0, $imagepath);
            $textWithImage = implode('', $textArray);
        }

        return $textWithImage ;

        }else {

            $textWithNoImage = $description ;

            return $textWithNoImage ;

        }

        
  
      }


}