Sindbad~EG File Manager

Current Path : /home/numerotech/public_html/livemt2023.aios-scientificcommittee.org/app/models/
Upload File :
Current File : //home/numerotech/public_html/livemt2023.aios-scientificcommittee.org/app/models/Category.php

<?php


class Category extends Eloquent {

	protected $primaryKey = 'category_id';
	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'categories';

	// public Static function IC()
 //    {
 //        try
 //        {


 //           $data = Category::where('abstract_type','IC')->get(); 

 //           $child = [];

	// 	   $parent_category = [];           
 //           foreach ($data as $key => $value) {           	 	
	// 	       	$parent_category[] = $value->parent_category_id;           	
	// 	       	if($value->parent_category_id != $value->category_id)
	// 			{ 
	// 			    $child[$value->parent_category_id][] = $value;
	// 			}
 //           }
           
 //           $data_parent = Category::where('abstract_type','IC')->whereIn('category_id',array_unique($parent_category))->get(); 
           
 //           $categories = [];
 //           foreach ($data_parent as  $value) {            	
 //           	 if(isset($child[$value->category_id])>0)
 //           	 {
 //           	 	foreach ($child[$value->category_id] as $val_child) {
 //           	 		$categories[$value->name][$val_child->category_id]=$val_child->name;	
 //           	 	}
 //           	 }            	
 //           }

 //           return $categories;

 //        } catch (Exception $e)
 //        {
 //            Log::error('Models: Category  -> IC '.$e->getMessage());
 //            return [];
 //        }
 //    }

	public Static function IC()
    {
        try
        {

          $categories = ["10"=>"Cataract -> Challenging cases"
                        ,"8"=>"Cataract -> Complications"
                        ,"4"=>"Cataract -> Devices – OVD, CTR, Segments"
                        ,"5"=>"Cataract -> Intra Ocular Lenses"
                        ,"7"=>"Cataract -> Medications"
                        ,"11"=>"Cataract -> Newer advances and future"
                        ,"12"=>"Cataract -> Others"
                        ,"6"=>"Cataract -> Posterior Capsular Opacification"
                        ,"9"=>"Cataract -> Refractive outcomes & Astigmatism Management"
                        ,"3"=>"Cataract -> SICS"
                        ,"2"=>"Cataract -> Surgical Techniques and Technology for lens removal in Phacoemulsification"
                        ,"21"=>"Community / Social Ophthalmology"
                        ,"37"=>"Comprehensive Ophthalmology -> Basic procedures like (Refraction/slit lamp examination
                        , Indirect Ophthalmoscopy)"
                        ,"34"=>"Comprehensive Ophthalmology -> Career Guidance for young Ophthalmologists"
                        ,"32"=>"Comprehensive Ophthalmology -> Computers in Ophthalmology"
                        ,"35"=>"Comprehensive Ophthalmology -> Insurance in Ophthalmology"
                        ,"36"=>"Comprehensive Ophthalmology -> Newer innovations"
                        ,"39"=>"Comprehensive Ophthalmology -> Others"
                        ,"33"=>"Comprehensive Ophthalmology -> Practice & Hospital Management"
                        ,"38"=>"Comprehensive Ophthalmology -> Vision impairment / Blindness"
                        ,"42"=>"Cornea -> Corneal Infections"
                        ,"45"=>"Cornea -> Keratoconus / Ectasia"
                        ,"44"=>"Cornea -> Medications"
                        ,"46"=>"Cornea -> Others"
                        ,"43"=>"Cornea -> Surgical techniques and Technology"
                        ,"51"=>"External Disease"
                        ,"66"=>"Glaucoma -> Complications"
                        ,"68"=>"Glaucoma -> Imaging (NFL / OCT / Anterior segment etc.,)"
                        ,"64"=>"Glaucoma -> Laser Treatment"
                        ,"62"=>"Glaucoma -> Medical Management"
                        ,"67"=>"Glaucoma -> New Technology"
                        ,"69"=>"Glaucoma -> Others"
                        ,"65"=>"Glaucoma -> Surgery / Study Analysis"
                        ,"63"=>"Glaucoma -> Surgical Treatment"
                       // ,"71"=>"Inflammation"
                        ,"101"=>"Lacrimal"
                        ,"111"=>"Neuro Ophthalmology"
                        ,"131"=>"Ocular Pathology / Ocular Oncology and Tumors"
                       // ,"302"=>"Ophthalmic Education,  Epidemiology & Prevention of Blindness"
                        ,"121"=>"Optics / Refraction / Contact Lens"
                        ,"144"=>"Orbit & Oculoplasty -> Cosmetic procedures"
                        ,"145"=>"Orbit & Oculoplasty -> Evaluation and Investigation"
                        ,"143"=>"Orbit & Oculoplasty -> Lid conditions and their management"
                        ,"142"=>"Orbit & Oculoplasty -> Orbit"
                        ,"146"=>"Orbit & Oculoplasty -> Others"
                        ,"156"=>"Pediatric -> Cataract Surgery"
                        ,"159"=>"Pediatric -> Examination and assessment in Pediatric Ophthalmology"
                        ,"157"=>"Pediatric -> Glaucoma"
                        ,"160"=>"Pediatric -> Others"
                        ,"158"=>"Pediatric -> Retinal Disease"
                        ,"155"=>"Pediatric -> Strabismus -> Diagnostics and assessment"
                        ,"154"=>"Pediatric -> Strabismus -> Non surgical management"
                        ,"153"=>"Pediatric -> Strabismus -> Surgical Procedure"
                        ,"87"=>"Refractive Surgery -> Complications"
                        ,"88"=>"Refractive Surgery -> Corneal Biomechanics"
                        ,"86"=>"Refractive Surgery -> Femto Second Lasers"
                        ,"89"=>"Refractive Surgery -> Investigation and evaluation"
                        ,"82"=>"Refractive Surgery -> Lasik"
                        ,"91"=>"Refractive Surgery -> Others"
                        ,"90"=>"Refractive Surgery -> Phakic IOL"
                        ,"85"=>"Refractive Surgery -> Presbyopia"
                        ,"83"=>"Refractive Surgery -> Surface ablation [PRK / LASEK / EPI LASIK]"
                        ,"84"=>"Refractive Surgery -> Wave front ablation"
                        ,"171"=>"Trauma"
                        ,"181"=>"Uvea"
                        ,"164"=>"Vitreo Retinal Diseases -> Diagnostics"
                        ,"162"=>"Vitreo Retinal Diseases -> Medical Retina"
                        ,"165"=>"Vitreo Retinal Diseases -> Others"
                        ,"163"=>"Vitreo Retinal Diseases -> Surgical Vitreo Retina"];

           return $categories;

        } catch (Exception $e)
        {
            Log::error('Models: Category  -> IC '.$e->getMessage());
            return [];
        }
    }

    public Static function ICParent()
    {
        try
        {
           //$categories = Category::where('is_ic','1')->where('is_parent','1')->orderby('name')->lists('display_name','category_id'); ; 
		$categories = Category::where('is_ic', '=', '1')->where('is_parent', '=', '1')->orderBy('name')->select('display_name', 'category_id')->get();
           

           
           return $categories;

        } 
        catch (Exception $e)
        {
            Log::error('Models: Category  -> ICParent '.$e->getMessage());
            return [];
        }
    }
 public Static function FPParent()
    {
        try
        {
           //$categories = Category::where('is_fp','1')->orderby('name')->lists('name','Category_id'); ; 

            $categories = Category::where('is_fp','1')->orderBy('name')->select('display_name', 'category_id')->get();
           
           return $categories;

        } catch (Exception $e)
        {
            Log::error('Models: Category  -> FPParent '.$e->getMessage());
            return [];
        }
    }
    
    public Static function PTParent()
    {
        try
        {
           //$categories = Category::where('is_fp','1')->orderby('name')->lists('name','Category_id'); ; 

            $categories = Category::where('is_arc','1')->orderBy('name')->select('display_name', 'category_id')->get();
           
           return $categories;

        } catch (Exception $e)
        {
            Log::error('Models: Category  -> PTParent '.$e->getMessage());
            return [];
        }
    }

    public Static function VTParent()
    {
        try
        {
           //$categories = Category::where('is_vt','1')->orderby('name')->lists('name','Category_id'); ; 
           $categories = Category::where('is_vt','1')->orderBy('name')->select('display_name', 'category_id')->get();
           
           return $categories;

        } catch (Exception $e)
        {
            Log::error('Models: Category  -> VTParent '.$e->getMessage());
            return [];
        }
    }
       
	public Static function FP()
    {
        try
        {
           $categories = Category::where('is_fp','1')->orderby('name')->lists('name','Category_id'); ; 
           
           return $categories;

        } catch (Exception $e)
        {
            Log::error('Models: Category  -> FP '.$e->getMessage());
            return [];
        }
    }
    
    public Static function PT()
    {
        try
        {
           $categories = Category::where('is_arc','1')->orderby('name')->lists('name','Category_id'); ; 
           
           return $categories;

        } catch (Exception $e)
        {
            Log::error('Models: Category  -> PT '.$e->getMessage());
            return [];
        }
    }
    
    public Static function VT()
    {
        try
        {

           $categories = Category::where('is_vt','1')->orderby('name')->lists('name','Category_id'); ; 
           
           return $categories;

        } catch (Exception $e)
        {
            Log::error('Models: Category  -> VT '.$e->getMessage());
            return [];
        }
    }


    public Static function VTProfile()
    {
        try
        {
            //category_id 322 is PG/Fellow
           $categories = Category::where('is_vt','1')->orWhere('category_id',322)->orderby('name')->lists('name','Category_id'); ; 
           
           return $categories;

        } catch (Exception $e)
        {
            Log::error('Models: Category  -> VT '.$e->getMessage());
            return [];
        }
    }


    public Static function ARC()
    {
        try
        {
           $categories = Category::where('is_arc','1')->orderby('name')->lists('name','Category_id'); ; 
           
           return $categories;

        } catch (Exception $e)
        {
            Log::error('Models: Category  -> ARC '.$e->getMessage());
            return [];
        }
    }

    public Static function AppleTree()
    {
        try
        {
           $categories = Category::where('is_appletree','1')->orderby('name')->lists('name','Category_id'); ; 
           
           return $categories;

        } catch (Exception $e)
        {
            Log::error('Models: Category  -> AppleTree '.$e->getMessage());
            return [];
        }
    }
    public Static function getForum($userID,$now,$lastWeek)
    {
        try
        {
       
            if($userID > 0)
                     $categories =  DB::table("categories as c")
                           ->leftJoin(DB::raw("(select `ms`.`category_id`, concat('Moderators : ',GROUP_CONCAT(concat(COALESCE(u.prefix,''),' ',COALESCE(u.first_name,'')) SEPARATOR ', ')) as moderators from `moderator_section` as `ms` left join `users` as `u` on `u`.`user_id` = `ms`.`user_id` where `ms`.`deleted_at` is null and `u`.`is_tech_moderator` = 0 group by `ms`.`category_id`) as sq"),function($join)
                           {
                              $join->on("c.category_id", "=", "sq.category_id");
                           })
                            ->leftJoin(DB::raw("(select  
                                                c.category_id, count(c.category_id)  as unread_reply_count
                                                from replies r
                                                left join (select trr.replies_read_id,trr.reply_id from replies_read trr where  trr.user_id = ".$userID.") as rr on rr.reply_id = r.reply_id
                                                left join topics t on t.topic_id = r.topic_id
                                                left join categories c on c.category_id = t.category_id
                                                left join moderator_section ms on ms.category_id =  t.category_id   and ms.user_id = ".$userID."
                                                where
                                                    rr.replies_read_id  is  null   
                                                and (r.moderator_status =1 or ms.moderator_section_id is not null)
                                                -- and r.user_id not in (".$userID.")
                                                and 

                                                r.created_at >= '".$lastWeek->format('Y-m-d H:i:s')."'
                                                and 
                                                r.created_at <= '".$now->format('Y-m-d H:i:s')."'
                                                group by c.category_id) as mrr"),"mrr.category_id", "=", "c.category_id")
                           ->where("c.forum_is_visible", "=", 1)
                           ->select("c.*","sq.moderators", DB::raw("ifnull(mrr.unread_reply_count,0) as unread_reply_count"))
  
                           
                           ->get();  
                else
                     $categories =  DB::table("categories as c")
                                           ->leftJoin(DB::raw("(select `ms`.`category_id`, concat('Moderators : ',GROUP_CONCAT(concat(COALESCE(u.prefix,''),' ',COALESCE(u.first_name,'')) SEPARATOR ', ')) as moderators from `moderator_section` as `ms` left join `users` as `u` on `u`.`user_id` = `ms`.`user_id` where `ms`.`deleted_at` is null and `u`.`is_tech_moderator` = 0 group by `ms`.`category_id` ) as sq"),function($join)
                                           {
                                              $join->on("c.category_id", "=", "sq.category_id");
                                           })
                                           ->where("c.forum_is_visible", "=", 1)
                                           ->select("c.*","sq.moderators", DB::raw("0 as unread_reply_count"))
                                           ->get();

                                              
                      return $categories;



        } catch (Exception $e)
        {
            Log::error('Models: Category  -> getForum '.$e->getMessage());
            return [];
        }
    }

    /*Category drop down with count*/
    public Static function usp_get_dropdown_category($abs_type=null,$num_abstract=null,$num_evalu=null)
    {
       try
       {
            $categories    = array();
            
            $connection  = DB::connection();
            $pdo         = $connection->getPdo();
            $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);

            $stmnt = $pdo->prepare('CALL usp_get_dropdown_category(:abs_type,:num_abstract,:num_evalu);');
            $stmnt->bindParam(':abs_type',$abs_type, PDO::PARAM_STR);
            $stmnt->bindParam(':num_abstract',$num_abstract, PDO::PARAM_INT);
            $stmnt->bindParam(':num_evalu',$num_evalu, PDO::PARAM_INT);
           
            $stmnt->execute();

            while ($row = $stmnt->fetch())
            {
                array_push($categories, (object)$row);
            }
            $stmnt->closeCursor();

            return array('categories' => $categories);
        }
        catch (Exception $e)
        {
            Log::error('Models: Category  -> usp_get_dropdown_category '.$e->getMessage());
            return [];
        }
    }



    /*Category count*/
    public Static function usp_get_categorywise_status($category_id=null,$abs_type=null,$is_parent=null)
    {
        try
        {
            $parent_categories  = array();
            $child_categories   = array();
            $gender_wise        = array();
            $state_wise         = array();
            
            $pdo = DB::connection()->getPdo();
            $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
            $stmt = $pdo->prepare('CALL usp_get_categorywise_status(:category_id,:abs_type,:is_parent);');
            $stmt->execute(array(':category_id' => $category_id ,':abs_type' => $abs_type,':is_parent' => $is_parent));

            $i = 1;
            do
            {

                if($i == 1)
                {
                    while ($row = $stmt->fetch())
                    {
                        array_push($parent_categories, (object)$row);                        
                    }

                }

                elseif($i == 2)
                {
                    while ($row = $stmt->fetch())
                    {
                        array_push($child_categories,(object)$row);

                    }
                }   
          
                elseif($i == 3)
                {
                    while ($row = $stmt->fetch())
                    {
                        array_push($gender_wise,(object)$row);
                    }
                }

                elseif($i == 4)
                {
                    while ($row = $stmt->fetch())
                    {
                        array_push($state_wise,(object)$row);
                    }
                }

                $i++;
            } while ($stmt->nextRowset());

            return array('parent_categories' => $parent_categories,'child_categories' => $child_categories,
                         'gender_wise'=>$gender_wise,'state_wise'=>$state_wise);

        }
        catch (Exception $e)
        {
            Log::error('Models: Category  -> usp_get_categorywise_status '.$e->getMessage());
            return array('parent_categories' => [],'child_categories' => [],'gender_wise' =>[],'state_wise' =>[]);
        }
    }


}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists