0
I have a View
in the Laravel that shows the access key and the secret key of the api
user, these two keys are pulled from the database to the View
, i want to be able to edit only the access key when a change is needed, but I am having the following error in Views
:
Undefined Property: stdClass::$api_secret_Key
Follow the controllers I’m using:
Controller that returns to the API view (shows keys):
public function index()
{
$id = Auth::user()->id;
$user = DB::select("select * from users where id = '$id'");
return view('users.API', compact('user'));
}
Controller
edit
and update
:
public function edit(User $user)
{
return view('users.editApi', compact('user'));
}
public function update(UserRequest $request, User $user)
{
$user->update($request->all());
return redirect()->route('api.index');
}
how these controllers are called:
Edit:
@foreach($user as $user)
<input class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" name="api_access_key" id="input-name" type="text" value="{{ $user->api_access_Key }}" readonly="readonly required="true" aria-required="true"/>
</div>
<a href="{{ route('api.edit', $user->id) }}" class="btn btn-primary">{{ __('Editar') }}</a>
@endforeach
Update:
<form method="post" action="{{ route('api.update', $user) }}" autocomplete="off">
The problem seems to occur to me in this passage
value="{{ $user->api_access_Key }}"
,$user
has this propertyapi_access_Key
?, note that theK
key is in capital letters– Icaro Martins
Please make the error and copy the full text. I want to know if the error is in the view, model or controller.
– Risk
$id = Auth::user()->id; $user = DB::select("select * from users where id = '$id'");
these two lines are unnecessary, could use so$user = Auth::user()
...– novic