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


PHP Eloquent::with方法代碼示例

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


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

示例1: with

 /**
  * @param $include
  */
 public function with($include)
 {
     // include key
     if (!is_null($include)) {
         $relations = explode(',', $include);
         foreach ($relations as $relation) {
             // todo validate the nested relations
             $directRelation = explode('.', $relation)[0];
             if (in_array($directRelation, $this->relations)) {
                 $this->object = $this->object->with($relation);
             } else {
                 ParseHelper::throwException(102);
             }
         }
     }
 }
開發者ID:malimu,項目名稱:baas,代碼行數:19,代碼來源:ParseBaseController.php

示例2: applyWith

 function applyWith()
 {
     $with = $this->raw_with;
     foreach ($this->query_with as $path => $callbacks) {
         $with[$path] = function ($query) use($callbacks) {
             foreach ($callbacks as $c) {
                 $callback = Arr::get($c, 'callback');
                 $params = Arr::get($c, 'params', []);
                 call_user_func_array($callback, array_merge([$query], $params));
             }
         };
     }
     $tmp = [];
     ksort($with);
     foreach ($with as $path => $callback) {
         if ($path == $callback) {
             $tmp[] = $path;
         } else {
             $tmp[$path] = $callback;
         }
     }
     $this->model->with($tmp);
 }
開發者ID:larakit,項目名稱:lk,代碼行數:23,代碼來源:FormFilter.php

示例3: with

 /**
  * Begin querying a model with eager loading.
  *
  * @param  array|string  $relations
  */
 public function with($relations)
 {
     $this->model->with($relations);
     return $this;
 }
開發者ID:sharenjoy,項目名稱:cmsharenjoy,代碼行數:10,代碼來源:EloquentBaseRepository.php


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