Voyager: [SEVERE BUG] Illegal string offset 'locale'

Created on 7 Feb 2019  路  5Comments  路  Source: the-control-group/voyager

Version information

  • Laravel: v5.7.25
  • Voyager: v1.1
  • PHP: v7.1.3
  • MySql: 15.1 Distrib 10.1.36-MariaDB, for Win32 (AMD64)

Description

The Bug starts occurring when trying to update the user's profile and affects every /admin route registered in the app.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Setup Laravel
  2. composer require tcg/voyager
  3. php artisan voyager:install
  4. php artisan voyager:admin [email protected] --create
  5. Go to profile and change profile avatar and hit save.

Expected behavior

The avatar to change.

Screenshots

image
image

What I have tried

dd() -ing $this->settings in the getLocalAttribute() function on TCG\Voyager\Models\User.php like
image
gives:
image
Tried to json_decode it but it still doesn't work.
You can do dd(json_decode($this->settings)->locale) and it gives 'en'.

possible bug

Most helpful comment

As of 3 days ago, the default App\User model now includes a casts array to cast the email_verified_at attribute. Make sure it also casts settings as array, as it overrides the casts array on TCG\Voyager\Models\User.

class User extends \TCG\Voyager\Models\User
{
    protected $casts = [
        'email_verified_at' => 'datetime',
        'settings' => 'array',
    ];
}

All 5 comments

Please fill out the exact versions. This feature was working for month, so there might be a change in laravel

Please fill out the exact versions. This feature was working for month, so there might be a change in laravel

I have updated my question.

As of 3 days ago, the default App\User model now includes a casts array to cast the email_verified_at attribute. Make sure it also casts settings as array, as it overrides the casts array on TCG\Voyager\Models\User.

class User extends \TCG\Voyager\Models\User
{
    protected $casts = [
        'email_verified_at' => 'datetime',
        'settings' => 'array',
    ];
}

@citrtech's solution works, but don't forget to launch a php artisan cache:clear after this modification. Sometimes it could not work just with code modification.

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ferrywae picture ferrywae  路  4Comments

winex01 picture winex01  路  3Comments

wislem picture wislem  路  3Comments

craigb88 picture craigb88  路  3Comments

zzpwestlife picture zzpwestlife  路  3Comments