Format phone number in Laravel Blade

Solution:1

Feel free to use the following package: https://github.com/Propaganistas/Laravel-Phone

and use it for example:

{{ phone('612345678'); }}
{{ phone($user['phone'], 'US'); }}

Solution:2

add the function in the model

public function phoneNumber() {
    // add logic to correctly format number here
    // a more robust ways would be to use a regular expression
    return "(".substr($data, 0, 3).") ".substr($data, 3, 3)." ".substr($data,6);
}

and display it into your blade as

{{ $user->phoneNumber() }}