Sunday, April 2, 2017

String Format Get Attribute Function

I try to create an attribute fonction in a model who return a string result but I would like to change the format of the string .

Actually I have a number licence (varchar column) .who is display like 17923457 and I would like to change the format like 17-92-3457 .

My function attribute actually is like :

public function getNumberAttribute() {

return $this->num_licence ;

}

Someone knows how I can display that specific format ? Thanks a lot in advance



via Mathieu Mourareau

Advertisement