Open Hi7cl4w opened 5 years ago
You need to provide much much more information. I'm not able to reproduce this at first sight.
You need to provide much much more information. I'm not able to reproduce this at first sight.
The error came up after upgrading the voyager version from 1.1 to 1.2
Still not enough. Lets start with the required informations from the issue template:
Also, did you override anything? Models, Views, Controller?
Still not enough. Lets start with the required informations from the issue template:
- Steps to reproduce
- Full stacktrace
Also, did you override anything? Models, Views, Controller?
@emptynick
edit-add.blade.php
@extends('voyager::master')
@section('page_title', __('voyager::generic.'.(isset($dataTypeContent->id) ? 'edit' : 'add')).' '.$dataType->display_name_singular)
@section('css')
<meta name="csrf-token" content="{{ csrf_token() }}">
@stop
@section('page_header')
<h1 class="page-title">
<i class="{{ $dataType->icon }}"></i>
{{ __('voyager::generic.'.(isset($dataTypeContent->id) ? 'edit' : 'add')).' '.$dataType->display_name_singular }}
</h1>
@stop
@section('content')
<div class="page-content container-fluid">
<form class="form-edit-add" role="form"
action="@if(!is_null($dataTypeContent->getKey())){{ route('voyager.'.$dataType->slug.'.update', $dataTypeContent->getKey()) }}@else{{ route('voyager.'.$dataType->slug.'.store') }}@endif"
method="POST" enctype="multipart/form-data" autocomplete="off">
<!-- PUT Method if we are editing -->
@if(isset($dataTypeContent->id))
{{ method_field("PUT") }}
@endif
{{ csrf_field() }}
<div class="row">
<div class="col-md-8">
<div class="panel panel-bordered">
{{-- <div class="panel"> --}}
@if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<div class="panel-body">
<div class="form-group">
<label for="name">{{ __('voyager::generic.name') }}</label>
<input type="text" class="form-control" id="name" name="name" placeholder="{{ __('voyager::generic.name') }}"
value="{{ $dataTypeContent->name ?? '' }}">
</div>
<div class="form-group">
<label for="email">{{ __('voyager::generic.email') }}</label>
<input type="email" class="form-control" id="email" name="email" placeholder="{{ __('voyager::generic.email') }}"
value="{{ $dataTypeContent->email ?? '' }}">
</div>
<div class="form-group">
<label for="username">Username</label>
<input type="username" class="form-control" id="username" name="username" placeholder="Username"
value="@if(isset($dataTypeContent->username)){{ $dataTypeContent->username }}@endif">
</div>
<div class="form-group">
<label for="password">{{ __('voyager::generic.password') }}</label>
@if(isset($dataTypeContent->password))
<br>
<small>{{ __('voyager::profile.password_hint') }}</small>
@endif
<input type="password" class="form-control" id="password" name="password" value="" autocomplete="new-password">
</div>
@can('editRoles', $dataTypeContent)
<div class="form-group">
<label for="default_role">{{ __('voyager::profile.role_default') }}</label>
@php
$dataTypeRows = $dataType->{(isset($dataTypeContent->id) ? 'editRows' : 'addRows' )};
$row = $dataTypeRows->where('field', 'user_belongsto_role_relationship')->first();
$options = $row->details;
@endphp
@include('voyager::formfields.relationship')
</div>
<div class="form-group">
<label for="additional_roles">{{ __('voyager::profile.roles_additional') }}</label>
@php
$row = $dataTypeRows->where('field', 'user_belongstomany_role_relationship')->first();
$options = $row->details;
@endphp
@include('voyager::formfields.relationship')
</div>
@endcan
@php
if (isset($dataTypeContent->locale)) {
$selected_locale = $dataTypeContent->locale;
} else {
$selected_locale = config('app.locale', 'en');
}
@endphp
<div class="form-group">
<label for="locale">{{ __('voyager::generic.locale') }}</label>
<select class="form-control select2" id="locale" name="locale">
@foreach (Voyager::getLocales() as $locale)
<option value="{{ $locale }}"
{{ ($locale == $selected_locale ? 'selected' : '') }}>{{ $locale }}</option>
@endforeach
</select>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel panel-bordered panel-warning">
<div class="panel-body">
<div class="form-group">
@if(isset($dataTypeContent->avatar))
<img src="{{ filter_var($dataTypeContent->avatar, FILTER_VALIDATE_URL) ? $dataTypeContent->avatar : Voyager::image( $dataTypeContent->avatar ) }}" style="width:200px; height:auto; clear:both; display:block; padding:2px; border:1px solid #ddd; margin-bottom:10px;" />
@endif
<input type="file" data-name="avatar" name="avatar">
</div>
</div>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary pull-right save">
{{ __('voyager::generic.save') }}
</button>
</form>
<iframe id="form_target" name="form_target" style="display:none"></iframe>
<form id="my_form" action="{{ route('voyager.upload') }}" target="form_target" method="post" enctype="multipart/form-data" style="width:0px;height:0;overflow:hidden">
{{ csrf_field() }}
<input name="image" id="upload_file" type="file" onchange="$('#my_form').submit();this.value='';">
<input type="hidden" name="type_slug" id="type_slug" value="{{ $dataType->slug }}">
</form>
</div>
@stop
@section('javascript')
<script>
$('document').ready(function () {
$('.toggleswitch').bootstrapToggle();
});
</script>
@stop
I also have this issue. @emptynick
Same stack. When creating a new user or updating users from the admin... it throws this error upon saving.
Still not enough information here. Thats why I requested them above.
add code in App\User
public function setSettingsAttribute($value) { $this->attributes['settings'] = $value ? $value->toJson() : null; }
And in /admin/bread/users/edit (Users BREAD) Model name: App\User
I've the same problem here. I'm not on a fresh install but steps to reproduce would be to try to edit a user through the admin section.
Error :
Call to a member function toJson() on null {"userId":1,"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Call to a member function toJson() on null at /var/www/vendor/tcg/voyager/src/Models/User.php:30)
Stacktrace :
[stacktrace]
#0 /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(611): TCG\\Voyager\\Models\\User->setSettingsAttribute(NULL)
#1 /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(565): Illuminate\\Database\\Eloquent\\Model->setMutatedAttributeValue('settings', NULL)
#2 /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1531): Illuminate\\Database\\Eloquent\\Model->setAttribute('settings', NULL)
#3 /var/www/vendor/tcg/voyager/src/Http/Controllers/Controller.php(110): Illuminate\\Database\\Eloquent\\Model->__set('settings', NULL)
#4 /var/www/vendor/tcg/voyager/src/Http/Controllers/VoyagerBaseController.php(287): TCG\\Voyager\\Http\\Controllers\\Controller->insertUpdateData(Object(Illuminate\\Http\\Request), 'users', Object(Illuminate\\Database\\Eloquent\\Collection), Object(TCG\\Voyager\\Models\\User))
#5 [internal function]: TCG\\Voyager\\Http\\Controllers\\VoyagerBaseController->update(Object(Illuminate\\Http\\Request), '1')
#6 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#7 /var/www/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('update', Array)
#8 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(TCG\\Voyager\\Http\\Controllers\\VoyagerBaseController), 'update')
#9 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\\Routing\\Route->runController()
#10 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php(680): Illuminate\\Routing\\Route->run()
#11 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#12 /var/www/vendor/tcg/voyager/src/Http/Middleware/VoyagerAdminMiddleware.php(24): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#13 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): TCG\\Voyager\\Http\\Middleware\\VoyagerAdminMiddleware->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#14 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#15 /var/www/wave/src/Http/Middleware/WaveMiddleware.php(29): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#16 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Wave\\Http\\Middleware\\WaveMiddleware->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#17 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#18 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#19 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#20 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#21 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(75): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#22 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#23 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#24 /var/www/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#25 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#26 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#27 /var/www/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(56): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#28 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#29 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#30 /var/www/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#31 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#32 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#33 /var/www/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#34 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#35 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#36 /var/www/vendor/devdojo/app/src/Http/Middleware/DemoThemeSwitcher.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#37 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): DevDojo\\App\\Http\\Middleware\\DemoThemeSwitcher->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#38 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#39 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#40 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php(682): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#41 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php(657): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#42 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php(623): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#43 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php(612): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#44 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#45 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#46 /var/www/app/Http/Middleware/HttpsRedirect.php(22): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#47 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): App\\Http\\Middleware\\HttpsRedirect->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#48 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#49 /var/www/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#50 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#51 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#52 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#53 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#54 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#55 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#56 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#57 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#58 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#59 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#60 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#61 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#62 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#63 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#64 /var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#65 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#66 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#67 /var/www/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#68 {main}
"}
@NurdaKz's line above to change in User
model fixed it on my side.
@NurdaKz's line above to change in
User
model fixed it on my side.
Follow the link: /admin/bread/users/edit
Change USER model name: App\User
Your current User Model: TCG\Voyager\Models\User
add code in App\User
public function setSettingsAttribute($value) { $this->attributes['settings'] = $value ? $value->toJson() : null; }
And in /admin/bread/users/edit (Users BREAD) Model name: App\User
This is an available patch.
Maybe you are using email validation (since Laravel 5.7). This is my case and I solved the problem by filling APP_DB -> users -> email_verified_at by current date ( NOW() )
For me, it happened because I have a settings
column on my users
table. Apparently, Voyager owns copyright to that name :)
Fix for me was to uncheck add
and edit
for my user's settings
property @admin/bread/users/edit.
TLDR; As long as you decide to use Voyager, avoid naming column with names used internally by Voyager.
Uncheck Settings "add" and "edit" and solved ability to add/edit users
Version information
Description of problem
The problem occurs when creating a new user which throws an error
at