當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Collection::reject方法代碼示例

本文整理匯總了PHP中Illuminate\Database\Eloquent\Collection::reject方法的典型用法代碼示例。如果您正苦於以下問題:PHP Collection::reject方法的具體用法?PHP Collection::reject怎麽用?PHP Collection::reject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Database\Eloquent\Collection的用法示例。


在下文中一共展示了Collection::reject方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: filterOnMethods

  /** After the Eloquent has run on the attributes and returned an eloquent collection,
   * this method takes the collection and $querySets as above, 
   * [$key=>['val'=>$val,'crit'=>$crit,'parm0'=>$parm0.....
   * @param Eloquent Collection $collection
   * @param array $querySets or null to take from local object
   */
  public function filterOnMethods(Collection $collection, $matchObjs=null) {
    //pkdebug("Yes, trying to filter.");
    if (!$matchObjs || !is_arrayish($matchObjs)) $matchObjs = $this->getMatchObjs();
    if (!$matchObjs || !is_arrayish($matchObjs)) return $collection;
    $numpre = count($matchObjs);
    $modelName = $collection-> getQueueableClass();
    //pkdebug("The num of match objs before: The QC is: [ $modelName ], the num $numpre -- is mine here?");
    //foreach ($matchObjs as $ma) { if ($ma->compfield == 'assetdebtratio') pkdebug("After buildQS, The MA is: ", $ma); }



    $trimmedMatches = PkMatch::filterMatchArr($matchObjs,
        ['modelName'=>$modelName,'modelMethods'=>true,'emptyCrit'=>true]);
    //pkdebug("The Trimmed Match Collection:", $trimmedMatches);
    if (!count($trimmedMatches)) return $collection;
    $trimmedCollection = $collection->reject(function ($item) use ($trimmedMatches) {
      foreach($trimmedMatches as $match) {
        $methodName = $match->method;
        $methodResult = $item->$methodName();
        $passed = $match->satisfy($methodResult);
        $reject = !$passed;
        if ($reject) return $reject;
      } ## Passed all the criteria; don't reject
      return false;
    });
    return $trimmedCollection;
  }
開發者ID:pkirkaas,項目名稱:PkExtensions,代碼行數:33,代碼來源:BuildQueryTrait.php

示例2: tweetable

 /**
  * Retrieve only those conferences which should be tweeted.
  *
  * @param \Illuminate\Database\Eloquent\Collection $conferences
  *
  * @return \Illuminate\Database\Eloquent\Collection
  */
 private function tweetable($conferences)
 {
     return $conferences->reject(function ($conference) {
         $starts = $conference->cfp_starts_at;
         $ends = $conference->cfp_ends_at;
         return $starts->isSameDay($ends);
     });
 }
開發者ID:jwalton512,項目名稱:symposium,代碼行數:15,代碼來源:TweetImportantCFPDates.php


注:本文中的Illuminate\Database\Eloquent\Collection::reject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。