当前位置: 首页>>代码示例>>PHP>>正文


PHP Model::__call方法代码示例

本文整理汇总了PHP中Illuminate\Database\Eloquent\Model::__call方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::__call方法的具体用法?PHP Model::__call怎么用?PHP Model::__call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Database\Eloquent\Model的用法示例。


在下文中一共展示了Model::__call方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __call

 /**
  * Handle polyglot dynamic method calls for locale relations.
  *
  * @param  string $method
  * @param  array  $parameters
  *
  * @return mixed
  */
 public function __call($method, $parameters)
 {
     // If the model supports the locale, load it
     if (in_array($method, $this->getAvailable())) {
         return $this->hasOne($this->getLangClass())->whereLang($method);
     }
     return parent::__call($method, $parameters);
 }
开发者ID:anahkiasen,项目名称:polyglot,代码行数:16,代码来源:Polyglot.php

示例2: __call

 /**
  * Handle dynamic method calls into the method.
  *
  * @param string $method
  * @param array  $parameters
  *
  * @return mixed
  */
 public function __call($method, $parameters)
 {
     // Unset method
     if ($method == 'unset') {
         return call_user_func_array([$this, 'drop'], $parameters);
     }
     return parent::__call($method, $parameters);
 }
开发者ID:dalejmooney,项目名称:laravel-google-datastore,代码行数:16,代码来源:Model.php

示例3: __call

 public function __call($method, $parameters)
 {
     $className = class_basename($this);
     $config = implode('.', ['relationship', $className, $method]);
     if (Config::has($config)) {
         $function = Config::get($config);
         return $function($this);
     }
     return parent::__call($method, $parameters);
 }
开发者ID:caffeinated,项目名称:beverage,代码行数:10,代码来源:Model.php

示例4: __call

 /**
  * Handle dynamic method calls into the model.
  *
  * @param  string $method
  * @param  array  $parameters
  *
  * @return mixed
  */
 public function __call($method, $parameters)
 {
     $relations = config('medialibrary.relations.attachment');
     if (array_has($relations, $method)) {
         return $this->morphedByMany($relations[$method], 'attachable', 'medialibrary_attachable');
     }
     if (starts_with($method, 'getUrl') && ends_with($method, 'Attribute') && $method !== 'getUrlAttribute') {
         return $this->getUrlAttribute(array_get($parameters, '0'));
     }
     return parent::__call($method, $parameters);
 }
开发者ID:cipemotion,项目名称:medialibrary,代码行数:19,代码来源:File.php

示例5: __call

 public function __call($method, $parameters)
 {
     #i: Convert array to dot notation
     $config = implode('.', ['asgard.block.config.relations', $method]);
     #i: Relation method resolver
     if (config()->has($config)) {
         $function = config()->get($config);
         return $function($this);
     }
     #i: No relation found, return the call to parent (Eloquent) to handle it.
     return parent::__call($method, $parameters);
 }
开发者ID:mikemand,项目名称:Block,代码行数:12,代码来源:Block.php

示例6: __call

 public function __call($method, $args)
 {
     preg_match('"([a-z]+)[A-Z$]"', $method, $match);
     $prefix = @$match[1];
     if ($prefix == 'pick' || $prefix == 'paginate') {
         $picker = $this->pick(substr($method, strlen($prefix)), @$args[0] ?: 10);
         if ($prefix == 'paginate') {
             $picker = $picker->paginate();
         }
         return $picker;
     }
     return parent::__call($method, $args);
 }
开发者ID:ankhzet,项目名称:Ankh,代码行数:13,代码来源:Entity.php

示例7: __call

 /**
  *
  * @param type $name
  * @param type $args
  * @return type
  */
 public function __call($name, $args)
 {
     foreach ($this->items as $item) {
         switch ($item->behavior) {
             case 'relationship':
                 if ($name === $item->relationship->method) {
                     return $this->relationshipDefaultModel($item);
                 }
                 break;
         }
     }
     return parent::__call($name, $args);
 }
开发者ID:wilcorrea,项目名称:awesovel,代码行数:19,代码来源:Model.php

示例8: __call

 /**
  * Handle dynamic method calls into the method.
  *
  * @param  string  $method
  * @param  array   $parameters
  * @return mixed
  */
 public function __call($method, $parameters)
 {
     if (substr($method, 0, 6) == "hasMtm") {
         $modelName = substr($method, 6);
         if (isset($parameters[1])) {
             array_push($parameters, $modelName);
         } else {
             array_push($parameters, null);
             array_push($parameters, $modelName);
         }
         return call_user_func_array(array($this, "hasMtm"), $parameters);
     }
     return parent::__call($method, $parameters);
 }
开发者ID:nilove,项目名称:motibubackend,代码行数:21,代码来源:Eloquent.php

示例9: __call

 /**
  * Handle dynamic method calls into the method.
  * Overrided from {@link Eloquent} to implement recognition of the {@link $relationsData} array.
  *
  * @param  string $method
  * @param  array  $parameters
  * @return mixed
  */
 public function __call($method, $parameters)
 {
     if ($this->autohash_attributes) {
         foreach ($this->attributes_schema as $key => $value) {
             $method_name = 'set' . studly_case($key) . 'Attribute';
             if ($value == 'hashed' && $method_name == $method) {
                 $this->hashed_originals[$key] = $parameters[0];
                 $this->attributes[$key] = Hash::make($parameters[0]);
                 return;
             }
         }
     }
     if ($this->autoserialize_attributes) {
         foreach ($this->attributes_schema as $key => $value) {
             $method_name = 'set' . studly_case($key) . 'Attribute';
             if ($value == 'array' && $method_name == $method) {
                 $this->attributes[$key] = serialize((array) $parameters[0]);
                 return;
             }
             if ($value == 'object' && $method_name == $method) {
                 $this->attributes[$key] = serialize((object) $parameters[0]);
                 return;
             }
             $method_name = 'get' . studly_case($key) . 'Attribute';
             if ($value == 'array' && $method_name == $method || $value == 'object' && $method_name == $method) {
                 return unserialize($parameters[0]);
             }
         }
     }
     return parent::__call($method, $parameters);
 }
开发者ID:fluentkit,项目名称:supermodel,代码行数:39,代码来源:SuperModel.php

示例10: __call

 /**
  * Magic method allowing the use of associatedXXXX() to access relation object
  *
  * @param string $method
  * @param array $parameters
  * @return mixed
  */
 public function __call($method, $parameters)
 {
     $proxy_methods = ['/^associated(.*)$/' => 'getAssociatedObject', '/^addAssociated(.*)$/' => 'addAssociatedObject', '/^countAssociated(.*)$/' => 'countAssociatedObject'];
     // Test each methods above to see if any match the name passed as parameter
     foreach ($proxy_methods as $regex => $method_name) {
         if (preg_match($regex, $method, $method_parameters)) {
             $parameters = array_merge(array_map('lcfirst', array_slice($method_parameters, 1)), $parameters);
             return call_user_func_array([$this, $method_name], $parameters);
         }
     }
     return parent::__call($method, $parameters);
 }
开发者ID:Jchedev,项目名称:laravel-evolved,代码行数:19,代码来源:Model.php

示例11: __call

 /**
  * @inheritdoc
  */
 public function __call($method, $arguments)
 {
     if ($relation = $this->getCustomRelation($method)) {
         return $relation;
     }
     return parent::__call($method, $arguments);
 }
开发者ID:redstarxz,项目名称:flarumone,代码行数:10,代码来源:Model.php

示例12: __call

 /**
  * Check for and execute custom relationships.
  *
  * @param string $name
  * @param array $arguments
  * @return mixed
  */
 public function __call($name, $arguments)
 {
     if (isset(static::$relationships[$name])) {
         array_unshift($arguments, $this);
         return call_user_func_array(static::$relationships[$name], $arguments);
     }
     return parent::__call($name, $arguments);
 }
开发者ID:Qiang1234,项目名称:core,代码行数:15,代码来源:Model.php

示例13: __call

 /**
  * Using extensions
  *
  * @param string $method
  * @param array $parameters
  * @return mixed
  */
 public function __call($method, $parameters)
 {
     // Check method language
     if (in_array($method, static::$availableLanguages) && isset($parameters[0])) {
         return $this->getAttributeByLanguage($parameters[0], $method);
     }
     // Check extension methods
     if ($this->usesMethod($method)) {
         return $this->useMethod($method, $parameters);
     }
     // Check get attribute method
     if (substr($method, 0, 3) === 'get') {
         return $this->getAttribute(Str::snake(substr($method, 3, -strlen('attribute'))));
     }
     return parent::__call($method, $parameters);
 }
开发者ID:lifeentity,项目名称:eloquent,代码行数:23,代码来源:Model.php

示例14: __call

 public function __call($method, $parameters)
 {
     $d = $this->getRelational($method);
     if ($d !== false) {
         return $d;
     }
     return parent::__call($method, $parameters);
 }
开发者ID:kevupton,项目名称:ethereal,代码行数:8,代码来源:Ethereal.php

示例15: __call

 /**
  * Handle dynamic method calls into the method.
  * Overrided from {@link Eloquent} to implement recognition of the {@link $relationsData} array.
  *
  * @param  string $method
  * @param  array  $parameters
  * @return mixed
  */
 public function __call($method, $parameters)
 {
     if (array_key_exists($method, static::$relationsData)) {
         return $this->handleRelationalArray($method);
     }
     return parent::__call($method, $parameters);
 }
开发者ID:tatu-carreta,项目名称:mariasanti_v2,代码行数:15,代码来源:Ardent.php


注:本文中的Illuminate\Database\Eloquent\Model::__call方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。