$ client-> id가 Laravel 5.2에서 올바른 값을 반환하지 않는 OauthClient 모델이 있습니다.Laravel Eloquent 모델 ID가 문자열 반환 값이 잘못되었습니다.
"lucadegasperi/oauth2-server-laravel": 마이그레이션시 "^ 5.1"이 사용되었습니다. $ table-> string ('id', 40) -> primary();
그러나 블레이드 템플릿에 $ client-> id를 사용하면 다시 "0"이됩니다. dd ($ client)를 사용하면 id 속성에 올바른 값이 표시됩니다.
무엇이 잘못 될 수 있습니까? DD에서
모델의 출력()에서
OauthClient {#254 ▼
#connection: null
#table: null
#primaryKey: "id"
#keyType: "int"
#perPage: 15
+incrementing: true
+timestamps: true
#attributes: array:7 [▼
"id" => "wISw4JmlMQCCrMupjojcuDTK3k4hwtkb"
"secret" => "nnw3CPTzeQSIfT4KpR0d3XzWIKKoghB3"
"name" => "http://example.com"
"package" => "free"
"user_id" => 2
"created_at" => "2016-07-19 15:36:28"
"updated_at" => "2016-07-19 15:36:28"
]
#original: array:7 [▶]
#relations: []
#hidden: []
#visible: []
#appends: []
#fillable: []
#guarded: array:1 [▼
0 => "*"
]
#dates: []
#dateFormat: null
#casts: []
#touches: []
#observables: []
#with: []
#morphClass: null
+exists: true
+wasRecentlyCreated: false
}
테이블 구조
CREATE TABLE `oauth_clients` (
`id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`secret` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`package` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`user_id` int(10) unsigned NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `oauth_clients_id_secret_unique` (`id`,`secret`),
KEY `oauth_clients_user_id_foreign` (`user_id`),
CONSTRAINT `oauth_clients_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
당신은 그것은 일반적이지 않습니다'DD ($ 클라이언트)' –
의 출력을 게시 할 수 있습니다. 일반적으로 모든 속성은 속성 배열 내에 보관되며, 적절한 것을 얻는 마법의'__get' 메쏘드가 있습니다. 우리는 당신의'OauthClient' 모델이 어떻게 보이는지 볼 필요가 있습니다. – apokryfos
추가 dd() 출력 및 테이블 구문 생성 –