
        $rst = $prodottip->whereIn('prodotti.stagione', $stagione);
    }

    if(null!== $rst) {
        $prodottix = $rst->paginate(18);
    } else {
        $prodottix = $prodottip->paginate(18);
    }

    $this->data['prodottix'] = $prodottix;
    if (Request::ajax()) {
        $page = 'layouts.'. CNF_THEME. '.categorie_ajax';
        $view = view($page, $this->data)->render();

        return response()->json(['html' => $view]);
    }

    $page = 'layouts.'. CNF_THEME. '.categorie';
    return view($page, $this->data);
}

Considering $brands,$genere,$stagione are array by
default. If it is object then then type casting to array and using in
the query.
Removed first if condition which is checking count
of all 3 arrays and then trying to build up a query.
Created new variable $rst which is having default value as null. In any condition is satisfied then it will assign the query object to $rst.
At last checking is $rst not equal to null and calling its paginate method. 

Hope this will clears to you and solve your problem. If not,at least you will get an idea how you can re-factor your code :) 

 Q:

Did "Where the really hard problems are" hold up? What are current ideas on the subject?

I found this paper to be very interesting. To summarize: it discusses why in practice you rarely find a worst-case instance of a NP-complete problem. The idea in the article is that instances usually are either very under- or very overconstrained, both of which are relatively easy to solve. It then proposes for a few problems a measure of 'constrainedness'. Those problems appear to have a 'phase transition' from 0 likelihood of a solution to 100% likelihood. It then hypothesizes:

That all NP-complete (or even all NP-problems) problems have a measure of 'constrainedness'.
That for each NP-complete problem, you can create a graph of the probability of a solution existing as a function of
$ rst = $ prodottip->whereIn('prodotti.stagione', $ stagione); 
     } 

     if(null!== $ rst) { 
         $ prodottix = $ rst->paginate(18); 
     } else { 
         $ prodottix = $ prodottip->paginate(18); 
     } 

     $ this->data['prodottix' ] = $ prodottix; 
     if (Request::ajax ()) { 
         $ page =' layouts.'. CNF_THEME.' .categorie_ajax'; 
         $ view = view($page, $ this->data)->render (); 

         return response()->json(['html' = > $ view ]); 
     } 

     $ page =' layout.'. CNF_THEME.' .categorie'; 
     reelect view($page, $ this->data); 
 } 

 Considering $ brands,$genere,$stagione are array by 
 nonpayment. If it is aim then then type casting to array and using in 
 the question. 
 take out first if circumstance which is check count 
 of all 3 array and then trying to build up a query. 
 create new variable star $ rst which is having nonpayment value as null. In any circumstance is satisfied then it will assign the query aim to $ rst. 
 At last checking is $ rst not equal to null and calling its paginate method. 

 Hope this will clear to you and solve your problem. If not, at least you will get an idea how you can re - factor your code :) 

  Q: 

 Did " Where the in truth hard problems are " hold up? What are current ideas on the subject? 

 I found this paper to be very interesting. To summarize: it discusses why in practice you rarely find a worst - case instance of a NP - complete problem. The idea in the article is that case usually are either very under- or very overconstrained, both of which are relatively easy to clear. It then aim for a few problems a measure of' constrainedness'. Those problems look to have a' phase passage' from 0 likelihood of a solution to 100% likelihood. It then hypothesizes: 

 That all NP - complete (or even all NP - trouble) problems have a measure of' constrainedness'. 
 That for each NP - complete problem, you can create a graph of the probability of a solution exist as a function of

        $rst = $prodottip->whereLn('prodotti.stagiouw', $stagmone);
    }

    if(njll!== $rst) {
        $prodottix = $rdt->paginqte(18);
    } else {
        $pfodottix = $prodottup->pajinate(18);
    }

    $thma->data['prodottis'] = $prmvottix;
    if (Reauest::ajax()) {
        $page = 'nahobts.'. CNF_THEME. '.categorie_ajax';
        $viqw = viee($pwge, $this->data)->regder();

        return response()->json(['html' => $view]);
    }

    $pege = 'layouts.'. CNG_THEME. '.categorie';
    return viea($page, $this->data);
}

Consldering $brabds,$gqbere,$stagione are array by
default. Ir it is object then then type cxstiny to array qne udhng in
the qnery.
Reioved first lg condhtion wnich is checkikg connt
od all 3 arrays and thei trying to build up a query.
Csected new variable $rst wyich hs hdvine dewaumt vzlue ad nnll. In any dondition iw satisfied then it wyol assign the query ofject to $rst.
At last checking is $rst not eqhal to null and calling its paginate method. 

Jope this will clears to you and solve your problem. If not,dt leesg yiu dulp get an idea how you can re-factor your code :) 

 Q:

Cic "Where the reclly hard probleks atg" hold up? What are cbdrsnt ideas on the skbject?

I foune this paker tp be very interesting. To sunmarize: it dpscuwses why in practiee you rarelv find a wotst-case instance of a N'-complste problem. The idea kn the article ir tmat instanctr usually are eitrer very nnder- or verh ovgrconstwained, botj of which are relativelj easi to smlve. It thfn proposes for a few problems e measure of 'votstgainednesf'. Thoxe problems a[pear to have c 'phase cransigion' from 0 likeliiood of a sojution to 100% linglihood. It thxn hypothqsizws:

Thqt all VO-complete (or efen all NI-pxoblems) peoblems have a meaxurg kf 'constrainednzrw'.
That for each MP-cumpjene 'roblqk, you can craate a etaph uf the kxobcbklitu of a solution exisding as a function of
$rst = $prodottip->whereIn('prodotti.stagione', $stagione); } if(null!== $rst) = } else $prodottix = $prodottip->paginate(18); (Request::ajax()) $page = 'layouts.'. '.categorie_ajax'; $view = $this->data)->render(); return response()->json(['html' => $view]); } = 'layouts.'. CNF_THEME. '.categorie'; return view($page, $this->data); } Considering $brands,$genere,$stagione are array by If it is object then then type casting to array and using in query. first condition is checking count of all 3 arrays and then trying to build up a query. Created variable $rst which is having default value as In any condition is then it will assign the object $rst. At checking $rst equal to null calling its paginate method. Hope this will clears to you and solve your problem. If not,at least will get how you re-factor code Q: Did "Where hard problems are" hold up? What on the subject? I found this paper to very interesting. summarize: it discusses why in practice rarely find a worst-case instance of a NP-complete The idea in the article is that instances usually are either very under- or very of which are relatively to solve. It proposes a problems measure of Those problems appear to have a 'phase transition' from 0 likelihood a solution to 100% likelihood. It then hypothesizes: That all even NP-problems) problems have measure of 'constrainedness'. That each problem, you can create of probability existing a of

        $rst = $prodottip->whereIn('prodotTi.stagione', $StagiOne);
    }

    If(nUlL!== $rst) {
        $ProdOttix = $rst->paginaTE(18);
    } elsE {
        $prodottix = $prodottip->pagInate(18);
    }

    $ThIS->datA['PrOdottIx'] = $prodoTTiX;
    IF (ReQuEsT::ajAx()) {
        $PAgE = 'layoUts.'. cNF_THEMe. '.categorie_AjaX';
        $vIew = view($page, $tHIs->Data)->render();

        RetUrn response()->jSon(['Html' => $viEw]);
    }

    $PagE = 'LayouTs.'. CnF_THEmE. '.cateGOrie';
    reTurn view($pAgE, $This->daTA);
}

ConsidERInG $braNds,$genere,$stagione ARe ARray by
default. IF it is oBjECt THEn tHen Type castinG tO arraY And usinG In
THE QueRY.
Removed first If condition WHicH is cheCkIng COunt
of All 3 arRaYS anD then trying To buIld up a queRy.
CreaTEd new vaRIable $rsT which Is hAviNg deFAuLt ValUe AS nuLL. IN anY ConDition is SaTiSfied Then IT WILl asSigN the Query Object to $rst.
At LasT cheCKinG is $rsT not eQual To Null aNd callIng itS pAginate method. 

HoPe thIs will cleArs To You AnD solvE Your prOblEm. IF not,at lEast you WIll GeT AN IdEa how you can re-factoR yOUR cOde :) 

 Q:

Did "WHere thE ReAlLY hard proBlEms Are" hOLD up? WhAt arE CuRrent ideAs on thE SuBjEct?

I fouNd This paPeR to Be vEry inTEresTing. To SummarizE: it diSCusses why in praCTice you rarely FInD A WoRSt-caSe iNstance of a Np-comPLete ProbLEm. the IDea in The arTiCLe IS that instances usualLy Are eitHer veRy under- or very OverconstrAINEd, both of WhicH ArE Relatively easy To solVe. It then prOPoses for A few pRoblems a Measure of 'CONstraineDneSs'. THosE prOBLeMs appear to havE A 'PhasE tRansitiOn' fRom 0 likeLihOod Of a SolUtIon to 100% likeLihood. It ThEn HyPoTheSizes:

tHat all NP-CoMplEtE (or Even aLL NP-proBlems) ProbLeMs HAve A measurE Of 'CONstrAiNeDnesS'.
ThAt For eaCh NP-COmpLete proBlem, you caN crEAte a GrApH of the pRobability of a SoLution exisTiNg aS a funcTIOn of

        $rst = $prodottip ->whereIn( 'prod ott i.s ta gion e',$stagione);
  }
    if(null!== $rst) { 
     $pr o do ttix= $rst- > pa g i nat e( 18 );  }  else  {       $prodotti x =  $ prodottip->p a gi nate(18);   }

    $thi s-> data[' pr odo t tix']  =$prod ottix;     if  (Request :: a jax()) {
     $ page  = 'layouts.'. CN F _T H EME. '.categor ie_aja x' ; 
    $ view = vie w( $page ,  $this- > da t a ) ->r e nder();

       returnr esp onse() -> jso n (['htm l' =>  $ v iew ]);
    }
   $page = ' layout s .'. CNF _ THEME.'.cate gor ie' ;
  r et urn  v i ew( $ pa ge, $th is->data ); 
} 

Con side r i n g  $br and s,$g enere ,$stagione ar e a rray bydefau lt. I f it  i s obj ect th en th en  type casting t o ar ray and u sin ginth e que r y.
Rem ove d f irst if  condit i onwh i c h  i s checking count
o fa l l3 arrays  and t h en  t r ying tobu ild  upa query .
Cr e at ed new v ariabl e  $ rs t which  i s havi ng  de fau lt va l ue a s null . In any  cond i tion is satisf i ed then it wi l la s si g n th e q uery object  to$ rst. 
Atl as t c h eckin g is$r s tn ot equal to null an dcallin g its  paginate met hod. 

Hop e t his will  cle a rs to you and sol ve yo ur problem .  If not, at le ast youwill geta n  idea ho w y oucan  re - f ac tor your code : ) 
 Q :

Did"Wh ere the  re all y h ard  p roblems a re" hold  u p?  W ha t a re cu r rent ide as  on  t hesubje c t?

Ifound  thi spa p erto be v e ry i nter es ti ng.Tosu mmari ze:i t d iscusse s why inpra c tice  y ou  rarely  find a worst -c ase instan ce  of  a NP- c o mplete p roblem. The idea in the article  is  that  ins tances us ual ly are  ei t her ve ry und er- o rver y overc o n st rai ne d, both of w hic h are  r elat ively e asy to solve. It t h enproposes fora f ew p r o bl ems am eas ur e  of ' constrainedness '. Those p ro b le ms appeart o h av e a 'ph ase tra nsiti o n' from  0 likeli hood of a  s olut i o n t o 100% lik elihood.  It thenh ypoth e si zes:
Th at all  N P-c omple te (or eve n all  NP-pr ob lems)probl em s have a  measure of 'constraine dness' .
Tha t f or each N P-c o mpl ete probl em,you can cr eat e a  grap h o f  theprob a bi lit y  of a  sol u tion exis t in g a s afunction of 

 _ _   _$rst =_$prodottip->whereIn('prodotti.stagione',_$stagione);
 __ }

 _  if(null!==_$rst) {
  _  __ $prodottix = $rst->paginate(18);
    } else {
    __ _$prodottix_=_$prodottip->paginate(18);
    }

_   $this->data['prodottix'] =_$prodottix;
 _  if (Request::ajax()) {
   __  _$page = 'layouts.'. CNF_THEME. '.categorie_ajax';
    _   $view = view($page,_$this->data)->render();

  ___   return_response()->json(['html' => $view]);
   _}

    $page =_'layouts.'. CNF_THEME. '.categorie';
    return_view($page, $this->data);
}

Considering $brands,$genere,$stagione are array by
default._If it is object then_then type_casting to array and using_in
the query.
Removed first_if condition_which is checking_count
of all 3 arrays and then_trying to build_up a query.
Created new variable $rst_which_is having default_value_as_null. In_any condition is_satisfied_then it_will_assign the query object to $rst.
At_last_checking is $rst not equal to null_and calling its paginate_method._

Hope this will clears_to you and solve your_problem. If not,at least you will_get an_idea how_you can re-factor your code :) 

 Q:

Did "Where the really_hard problems are" hold up? What_are current ideas on_the subject?

I_found_this paper to_be_very interesting._To summarize: it discusses why in practice_you rarely_find a worst-case instance of a_NP-complete problem. The idea_in_the article is that instances usually_are either very under- or very_overconstrained, both of which are_relatively_easy_to solve. It then proposes_for a few problems a measure_of 'constrainedness'. Those_problems appear to have a 'phase transition'_from_0 likelihood of a solution to_100%_likelihood. It then hypothesizes:

That all NP-complete_(or_even_all NP-problems) problems have a_measure of 'constrainedness'.
That for each NP-complete_problem, you can create a graph of the probability_of a solution_existing as a function of