jeudi 17 août 2017

ErrorException: Trying to get property of non-object in Laravel 5 package after upgrade

I created my first Laravel package out of some old PHP script for Teamspeak auth service. The main app was running Laravel 4, but has now been upgraded to Laravel 5. My package worked before, but now does not.

The error -

[2017-08-17 22:04:29] local.ERROR: ErrorException: Trying to get property of non-object in /apppath/vendor/eveseat/services/src/Settings/Settings.php:86
Stack trace:
#0 /apppath/vendor/eveseat/services/src/Settings/Settings.php(86): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Trying to get p...', '/apppath/$
#1 /apppath/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(349): Seat\Services\Settings\Settings::Seat\Services\Settings\{closure}()
#2 /apppath/vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php(301): Illuminate\Cache\Repository->rememberForever('tHKT2R21Aa1VLKh...', Object(Closure))
#3 /apppath/bootstrap/cache/compiled.php(6468): Illuminate\Cache\CacheManager->__call('rememberForever', Array)
#4 /apppath/vendor/eveseat/services/src/Settings/Settings.php(101): Illuminate\Support\Facades\Facade::__callStatic('rememberForever', Array)
#5 /apppath/vendor/eveseat/services/src/Helpers/helpers.php(289): Seat\Services\Settings\Settings::get('main_character_...')
#6 /apppath/vendor/package/mypackage/src/Http/Controllers/Ts3Controller.php(33): setting('main_character_...')
#7 [internal function]: Seat\Ts3\Http\Controllers\Ts3Controller->getControls()

The offending function in Ts3Controller -

$APIcharacterID = $pheal->eveScope->CharacterID(array("names" => setting('main_character_name')));

The same call is made elsewhere in the parent package and still works, so the object still exists.

Pheal is not throwing errors and is completing API calls elswhere.

The Model being referenced -

namespace Seat\Services\Settings;

use Seat\Services\Models\UserSetting;
/**
 * Class Profile.
 * @package Seat\Services\Settings
 */
class Profile extends Settings
{
    /**
     * The options available for this Setting type.
     *
     * @var array
     */
    public static $options = [
        'sidebar'            => ['sidebar-full', 'sidebar-collapse'],
        'skins'              => [
        'skin-blue', 'skin-black', 'skin-purple', 'skin-green',
        'skin-red', 'skin-yellow', 'skin-blue-light', 'skin-black-light',
        'skin-purple-light', 'skin-green-light', 'skin-red-light',
        'skin-yellow-light',
    ],
    'thousand_seperator' => [' ', ',', '.'],
    'decimal_seperator'  => [',', '.'],
    'mail_threads'       => ['yes', 'no'],
];
/**
 * @var string
 */
protected static $prefix = 'profile';
/**
 * @var
 */
protected static $model = UserSetting::class;
/**
 * @var string
 */
protected static $scope = 'user';
/**
 * @var array
 */
protected static $defaults = [
    // UI
    'sidebar'             => 'sidebar-full',
    'skin'                => 'skin-black',
    'language'            => 'en',
    'mail_threads'        => 'yes',
    // Main Character
    'main_character_id'   => 1,
    'main_character_name' => null,
    // Numbers
    'thousand_seperator'  => ' ',
    'decimal_seperator'   => '.',
    // Notifications
    'email_notifications' => 'no',
    // Multi factor authentication
    'require_mfa'         => 'no',
];
}

Which is referenced in my controller here -

use Seat\Services\Settings\Profile;



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2vNg1ig
via IFTTT

Aucun commentaire:

Enregistrer un commentaire