concatenate names laravel guards

2

I receive the name of the logged in user with the following code:

{{ Auth::guard('profesor')->user()->nombre }}

I want to concatenate with the last name, how can I do it?

    
asked by Edgardo Escobar 23.06.2017 в 05:42
source

1 answer

1

It should be possible to solve with accessors in the model:

public function getNombreCompletoAttribute()
{
   return $this->nombre . ' ' . $this->apellido;
}

and you call it in the view:

{{ Auth::guard('profesor')->user()->nombre_completo }}

See more information in the documentation: link

    
answered by 23.06.2017 / 05:45
source