Laravel Defining An Accessors



namespace App;

use Illuminate\Database\Eloquent\Model;

class User extends Model
     * Get the user's first name.
     * @param  string  $value
     * @return string
    public function getFirstNameAttribute($value)
        return ucfirst($value);

Getting Accessor:

As you can see, the original value of the column is passed to the accessor, allowing you to manipulate and return the value. To access the value of the accessor, you may simply access the first_name attribute on a model instance:

$user = App\User::find(1);
$firstName = $user->first_name;