for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace Arcanesoft\Auth\Models\Presenters;
/**
* Class UserPresenter
*
* @package Arcanesoft\Auth\Models\Observers
* @author ARCANEDEV <[email protected]>
* @property string gravatar
* @property string hashed_id
* @property \Carbon\Carbon created_at
*/
trait UserPresenter
{
/* ------------------------------------------------------------------------------------------------
| Traits
| ------------------------------------------------------------------------------------------------
use HasherTrait;
| Getters & Setters
* Get the full name attribute or use the username if empty.
* @return string
public function getFullNameAttribute()
$fullName = trim("{$this->first_name} {$this->last_name}");
first_name
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
last_name
return empty($fullName) ? $this->username : $fullName;
username
}
* Get the since date attribute (translated).
public function getSinceDateAttribute()
return trans('auth::users.since', [
'date' => $this->created_at->toFormattedDateString()
]);
* Get the gravatar attribute.
public function getGravatarAttribute()
return gravatar()
->setDefaultImage('mm')->setSize(160)
->src($this->email);
email
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: