当前位置: 首页>>代码示例>>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;未经允许,请勿转载。