Hiding ( $Hidden ) password Laravel 7

Asked

Viewed 69 times

0

I need to hide the password to be seen or etc either in the bucket or whatever form, because I list the users in an administration pad, even using the Model with Hidden as below I can read the password.

{{ $user->password }}

The big question is to hide this format with -> as {{ $user->name }} and not {{ $user['name'] }} in the Blade.

I heartily thank you for a help, a big hug !

Model:

protected $hidden = [
        'password', 'remember_token',
    ];

Controller:

namespace App\Http\Controllers\Administrator;

use App\Http\Controllers\Controller;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Carbon;
--------------------------------------------------------------------------------------

public function list()
    {
        $users = User::all()->toArray();


        return view('Administrator.users', compact('users'));


    }

1 answer

0

To access the data with '->' you have to transform the array into an object.

See the example of transformation:

$array = ['nome' => 'João', 'email' => '[email protected]'];
echo $array['nome'];

$object = (object) $array;
echo $object->nome;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.