本文整理汇总了PHP中Illuminate\Database\Eloquent\Model::__get方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::__get方法的具体用法?PHP Model::__get怎么用?PHP Model::__get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Model
的用法示例。
在下文中一共展示了Model::__get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __get
public function __get($key)
{
if ($this->isEloquent()) {
return $this->data->__get($key);
}
return object_get($this->data, $key);
}
示例2: __get
/**
* Magic method to return the meta data like the post original fields
*
* @param string $key
* @return string
*/
public function __get($key)
{
if (!isset($this->{$key})) {
return $this->meta->{$key};
}
return parent::__get($key);
}
示例3: __get
/**
* {@inheritdoc}
*/
public function __get($key)
{
if (array_key_exists($key, $this->aliases)) {
$key = $this->aliases[$key];
}
return parent::__get($key);
}
示例4: __get
public function __get($key)
{
if (in_array($key, $this->translatable)) {
return $this->getTranslatable($key);
}
return parent::__get($key);
}
示例5: __get
/**
* A hack to allow avatar_url to be called on the result of Auth::user().
*
* @param string $key The variable to get
* @return mixed
*/
public function __get($key)
{
if ($key === 'avatar_url') {
return $this->getPresenter()->avatar_url;
}
return parent::__get($key);
}
示例6: __get
public function __get($key)
{
// Получить армию.
if ($key == 'army') {
return $this->castle ? $this->castle->army : null;
}
return parent::__get($key);
}
示例7: __get
public function __get($key)
{
if (array_key_exists($key, $this->personableAliases)) {
return $this->{$this->personableAliases[$key]};
} else {
return parent::__get($key);
}
}
示例8: __get
public function __get($key)
{
$columns = $this->getTableColumns();
if (array_key_exists($key, $this->attributes) || $this->hasGetMutator($key) || $this->relationLoaded($key) || method_exists($this, $key) || in_array($key, $columns)) {
return parent::__get($key);
}
return $this->getMeta($key);
}
示例9: __get
public function __get($name)
{
switch ($name) {
case 'fullname':
return "{$this->name} {$this->last_name}";
break;
}
return parent::__get($name);
}
示例10: __get
public function __get($key)
{
if ($key == 'email') {
if ($this->employee != null) {
return $this->employee->email;
} else {
return $this->getAttribute('email');
}
} else {
return parent::__get($key);
}
}
示例11: __get
public function __get($key)
{
if ($key == 'imageURL') {
return '/images/page/' . $this->page->id . '/' . $this->id . '.png';
} else {
if ($key == 'thumbURL') {
return '/images/page/' . $this->page->id . '/' . $this->id . '.thumbnail.png';
} else {
return parent::__get($key);
}
}
}
示例12: __get
public function __get($key)
{
if ($key == 'imageURL') {
return '/images/slider/' . $this->slider->id . '/' . $this->id . '.png';
} else {
if ($key == 'thumbURL') {
return '/images/slider/' . $this->slider->id . '/' . $this->id . '.thumbnail.png';
} else {
if ($key == 'height') {
return $this->image->height;
} else {
return parent::__get($key);
}
}
}
}
示例13: __get
/**
* Give the user access to the translated fields from the main model.
*
* @param string $key
* @return mixed|null
*/
public function __get($key)
{
if (!in_array($key, $this->translatable)) {
return parent::__get($key);
}
return !empty($this->translations->first()) ? $this->translations->first()->getAttribute($key) : null;
}
示例14: __get
public function __get($key)
{
try {
$class = get_class($this);
if (isset($class::$relationsData) && array_key_exists($key, $class::$relationsData)) {
if (!isset($this->relations[$key])) {
$relations = $this->{$key}();
$this->relations[$key] = $relations->getResults();
}
return $this->relations[$key];
}
return parent::__get($key);
} catch (NullMorphException $e) {
return null;
}
}
示例15: __get
public function __get($name)
{
if (preg_match('/pretty_(\\w+_at)/', $name, $matches)) {
$field = $matches[1];
$timestamp = $this->{$field};
if ($timestamp and is_a($timestamp, \Carbon\Carbon::class)) {
return $timestamp->format('Y-m-d H:i');
}
}
return parent::__get($name);
}