You could add in an alias in the app.php...
'aliases' => [
'User' => 'App\User',
...
I get the object both ways now in 5.0-dev
php artisan tinker
[1] > (new App\User);
// object(App\User)(
// 'incrementing' => true,
// 'timestamps' => true,
// 'exists' => false
// )
[2] > (new User);
// object(App\User)(
// 'incrementing' => true,
// 'timestamps' => true,
// 'exists' => false
// )
TerrePorter said:
You could add in an alias in the app.php...
'aliases' => [ 'User' => 'App\User', ...
I get the object both ways now in 5.0-dev
php artisan tinker [1] > (new App\User); // object(App\User)( // 'incrementing' => true, // 'timestamps' => true, // 'exists' => false // ) [2] > (new User); // object(App\User)( // 'incrementing' => true, // 'timestamps' => true, // 'exists' => false // )
#I found autoload solution i add composer.json "app" string
"classmap": [
....,
"app"
]
and delete namespace in app\User.php
and change config/auth.php model=>'App/User' to model=>'User'
Not that I know of, as far as I understand namespaces once it has a namespace that is the only way to access it.
You could also do the Use to alias it in the file.
use \App\User as User
#I found autoload solution i add composer.json "app" string
"classmap": [ ...., "app" ]
Humm, that didn't work for me.
Anyways, glad you figured it out.
TerrePorter said:
#I found autoload solution i add composer.json "app" string
"classmap": [ ...., "app" ]
Humm, that didn't work for me.
Anyways, glad you figured it out.
maybe.. you does not delete namespace in app\User.php
and execute composer dump-autoload -o
anyway very very thanks.
This worked for me:
"autoload": {
...
"": [
"app/Models/"
]
(I think it would be app/ if you didn't have Models directory)
then do composer dump-autoload
If you had already namespaced everything just do find and replace to remove your namespace declarations in the models and from in front of model references. (this was easy for us because we were using \App\Models might be harder if your'e using just \App)
Super easy for us! Wish I'd known how easy it was earlier would have saved tons of migration time (we did it half way before trying)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community