本文整理匯總了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);
}