This commit is contained in:
2023-01-11 11:00:43 +08:00
commit ff55141a1e
791 changed files with 177427 additions and 0 deletions

50
app/Traits/Macroable.php Normal file
View File

@@ -0,0 +1,50 @@
<?php
namespace App\Traits;
trait Macroable
{
use \Illuminate\Support\Traits\Macroable {
__call as macroCall;
}
/**
* @param string $key
* @return mixed
*/
public function getRelationValue($key)
{
$relation = parent::getRelationValue($key);
if (!$relation && static::hasMacro($key)) {
return $this->getRelationshipFromMethod($key);
}
return $relation;
}
/**
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
if (static::hasMacro($method)) {
return $this->macroCall($method, $parameters);
}
return parent::__call($method, $parameters);
}
/**
* @param string $method
* @param array $parameters
* @return mixed
*/
public static function __callStatic($method, $parameters)
{
return parent::__callStatic($method, $parameters);
}
}