This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
    Akhil
    
            
            
                    
                                            
        
    
        I have written a script to get theses rows but i am unable to put where condition for its attachment 'image'.
       $modelMusicCurrent = modelMusicCurrent::select('id','name','alias','created_at')
                        ->where('published', '=', 1)
                        ->where('is_trending', '=', 1)
                        ->where('is_deleted', '=', 0);
                            Last updated
    Akhil
    
            
            
                    
                                            
        
    
        How can i use orderBy for both Tables in has and master and where condition for "Has" too. Basically i want to use Where, OrderBy, and Limit with "Has" Realstionship output.
$modelTvShowHomeList = modelTvShow::where('published', '=', 1)
                                ->where('is_deleted', '=', 0)
                                ->orderBy('published_on', 'desc')
                                ->has('tvseasons')
                                ->skip(0)
                                ->take(4);
                            Last updated
    Akhil
    
            
            
                    
                                            
        
    
        NOt working "Has" Limit anf Order BY ........
    $modelTvShowHomeList = modelTvShow::where('published', '=', 1) 
     ->where('is_deleted', '=', 0) 
     ->orderBy('published_on', 'desc') 
     ->orWhereHas('tvseasons', function($q){ 
      $q->where('published', '=', 1)->orderBy('id', 'DESC')->skip(0)->take(1); 
     }) 
     ->skip(0) 
     ->take(4) 
     ->get();
                    
    Akhil
    
            
            
                    
                                            
        
    
        So finally some how ....taken the help from Laravel ............to find the solution.
                modelTvShow::where('published', '=', 1)
                                ->where('is_deleted', '=', 0)
                                ->orderBy('published_on', 'desc')
                                ->with(array('tvseasons' => function($s){
                                    $s->where('published', '=', 1)
                                    ->where('is_deleted', '=', 0)
                                    ->orderBy('published_on', 'desc')
                                    ->with(array('tvepisodes' => function($e){
                                        $e->where('published', '=', 1)
                                        ->where('is_deleted', '=', 0)
                                        ->orderBy('published_on', 'desc')
                                        ->skip(0)->take(3);
                                    }))->skip(0)->take(1);
                                }))->skip(0)->take(4)->get();
                            Last updated
1-5 of 5