本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例11: __call
/**
* @inheritdoc
*/
public function __call($method, $arguments)
{
if ($relation = $this->getCustomRelation($method)) {
return $relation;
}
return parent::__call($method, $arguments);
}
示例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);
}
示例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);
}
示例14: __call
public function __call($method, $parameters)
{
$d = $this->getRelational($method);
if ($d !== false) {
return $d;
}
return parent::__call($method, $parameters);
}
示例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);
}